fluke/devops-service/commands/stack.rb
2015-07-30 12:18:55 +02:00

41 lines
956 B
Ruby

require "commands/server"
require 'commands/commands_storage'
module StackCommands
include ServerCommands
extend self
def stack_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!
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
def bootstrap_stack_servers
end
CommandsStorage.add_job_lambda(
stack_bootstrap: stack_bootstrap_proc
)
end