fluke/devops-service/commands/stack.rb
Anton Martynov 5adbff376f fixed case
2015-08-20 22:15:34 +03:00

55 lines
1.4 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!
case stack.stack_status
when 'CREATE_IN_PROGRESS'
out << "."
out.flush
when 'CREATE_COMPLETE'
mongo.stack_update(stack)
out << "\nStack '#{stack.id}' status is now #{stack.stack_status}\n"
out.flush
return 0
when 'ROLLBACK_COMPLETE'
out << "\nStack '#{stack.id}' status is rolled back\n"
return 1
else
out << "\nUnknown status: '#{stack.stack_status}'"
return 2
end
end
rescue StandardError => e
logger.error e.message
out << "Error: #{e.message}\n"
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