module Patriot::Tool::PatriotCommands::WorkerAdmin
remote worker administration tool
Public Instance Methods
print_status(result, opts)
click to toggle source
# File lib/patriot/tool/patriot_commands/worker_admin.rb, line 37 def print_status(result, opts) statuses = {} unless opts[:all] raise "illegal response #{result} from #{opts[:host]}" unless result.size == 1 result[opts[:host]] = result.delete(result.keys.first) end result.each do |s,r| if r.nil? statuses[s] = 'HALT' else r = JSON.parse(r) raise "illegal response #{r} from #{s}" unless r.size == 1 statuses[s] = r.values[0].nil? ? 'HALT' : r.values[0] end end puts JSON.generate(statuses) end
worker_admin(sub_cmd)
click to toggle source
# File lib/patriot/tool/patriot_commands/worker_admin.rb, line 19 def worker_admin(sub_cmd) sub_cmd = "#{sub_cmd}_worker" unless sub_cmd == "status" begin opts = symbolize_options(options) conf = {:type => 'worker_admin'} conf[:path] = opts[:config] if opts.has_key?(:config) config = load_config(conf) controller = Patriot::Controller::WorkerAdminController.new(config) result = controller.send(sub_cmd.to_sym, opts) print_mtd ="print_#{sub_cmd}".to_sym self.send(print_mtd, result, opts) if self.respond_to?(print_mtd) rescue => e puts e raise e end end