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 << "\nStack '#{stack.id}' status is now #{stack.stack_status}\n" out.flush break end out << "." out.flush end out << "\n" 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