Skip to content

Commit

Permalink
Add term option to proc (grace period in seconds for shutdown)
Browse files Browse the repository at this point in the history
  • Loading branch information
collimarco committed Oct 31, 2022
1 parent be74114 commit ad89e5e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/cuber/cuberfile_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def migrate cmd, check: nil
@migrate = { cmd: cmd, check: check }
end

def proc name, cmd, scale: 1, env: {}
@procs[name] = { cmd: cmd, scale: scale, env: env }
def proc name, cmd, scale: 1, term: 60, env: {}
@procs[name] = { cmd: cmd, scale: scale, term: term, env: env }
end

def cron name, schedule, cmd
Expand Down
1 change: 1 addition & 0 deletions lib/cuber/cuberfile_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def validate_procs
@errors << "proc \"#{procname}\" name can only include lowercase letters" if procname !~ /\A[a-z]+\z/
@errors << "proc \"#{procname}\" command must be present" if proc[:cmd].to_s.strip.empty?
@errors << "proc \"#{procname}\" scale must be a positive number" unless proc[:scale].is_a?(Integer) && proc[:scale] > 0
@errors << "proc \"#{procname}\" term must be a positive number" unless proc[:term].is_a?(Integer) && proc[:term] > 0
proc[:env].each do |key, value|
@errors << "proc \"#{procname}\" env name can only include uppercase letters, digits or underscores" if key !~ /\A[A-Z_]+[A-Z0-9_]*\z/
end
Expand Down
1 change: 1 addition & 0 deletions lib/cuber/templates/deployment.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ spec:
<%- end -%>
imagePullSecrets:
- name: regcred
terminationGracePeriodSeconds: <%= proc[:term] %>
<%- end -%>
<%- @options[:cron].each do |jobname, cron| -%>
Expand Down
2 changes: 1 addition & 1 deletion lib/cuber/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Cuber
VERSION = '1.3.0'.freeze
VERSION = '1.4.0'.freeze
end

0 comments on commit ad89e5e

Please sign in to comment.