Allow performing boot & start operations in groups
Adds top-level configuration options for `group_limit` and `group_wait`. When a `group_limit` is present, we'll perform app boot & start operations on no more than `group_limit` hosts at a time, optionally sleeping for `group_wait` seconds after each batch. We currently only do this batching on boot & start operations (including when they are part of a deployment). Other commands, like `app stop` or `app details` still work on all hosts in parallel.
This commit is contained in:
@@ -13,7 +13,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
||||
execute *MRSK.app.tag_current_as_latest
|
||||
end
|
||||
|
||||
on(MRSK.hosts) do |host|
|
||||
on(MRSK.hosts, **MRSK.config.group_strategy) do |host|
|
||||
roles = MRSK.roles_on(host)
|
||||
|
||||
roles.each do |role|
|
||||
@@ -39,7 +39,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
||||
desc "start", "Start existing app container on servers"
|
||||
def start
|
||||
with_lock do
|
||||
on(MRSK.hosts) do |host|
|
||||
on(MRSK.hosts, **MRSK.config.group_strategy) do |host|
|
||||
roles = MRSK.roles_on(host)
|
||||
|
||||
roles.each do |role|
|
||||
|
||||
@@ -153,6 +153,15 @@ class Mrsk::Configuration
|
||||
end
|
||||
|
||||
|
||||
def group_strategy
|
||||
if group_limit.present?
|
||||
{ in: :groups, limit: group_limit, wait: group_wait }
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def audit_broadcast_cmd
|
||||
raw_config.audit_broadcast_cmd
|
||||
end
|
||||
@@ -237,4 +246,12 @@ class Mrsk::Configuration
|
||||
raise "Can't use commit hash as version, no git repository found in #{Dir.pwd}"
|
||||
end
|
||||
end
|
||||
|
||||
def group_limit
|
||||
raw_config.group_limit&.to_i
|
||||
end
|
||||
|
||||
def group_wait
|
||||
raw_config.group_wait&.to_i
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user