fluke/devops-service/commands/stack.rb
2015-08-17 17:50:24 +03:00

45 lines
1.1 KiB
Ruby

require 'commands/commands_storage'
module StackCommands
extend self
def sync_bootstrap_proc
lambda do |out, stack, mongo|
# two tries each 4 seconds, then 5 tries each 10 seconds, then 5 tries each minute.
sleep_times = [4]*2 + [10]*5 + [60]*5
begin
out << "Syncing stack '#{stack.id}'...\n"
sleep_times.each do |sleep_time|
sleep sleep_time
stack.sync_details!
puts stack.stack_status
if stack.stack_status != 'CREATE_IN_PROGRESS'
mongo.stack_update(stack)
out << "Stack '#{stack.id}' status is now #{stack.stack_status}"
break
end
out << "Next try...\n"
end
rescue StandardError => e
logger.error e.message
return 5
end
end
end
=begin
def bootstrap_stack_servers_proc(out, stack, mongo, provider, logger)
mongo.stack_servers(stack.id).each do |server|
key = mongo.key(server.key)
two_phase_bootstrap(server, out, provider, mongo, key.path, logger)
end
end
=end
CommandsStorage.add_job_lambda(
sync_bootstrap: sync_bootstrap_proc
)
end