Module: Eye::Controller::Commands
- Included in:
- Eye::Controller
- Defined in:
- lib/eye/controller/commands.rb
Constant Summary collapse
- NOT_IMPORTANT_COMMANDS =
[:info_data, :short_data, :debug_data, :history_data, :ping, :logger_dev, :match, :explain, :check]
Instance Method Summary collapse
-
#command(cmd, *args) ⇒ Object
Main method, answer for the client command.
Instance Method Details
#command(cmd, *args) ⇒ Object
Main method, answer for the client command
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/eye/controller/commands.rb', line 7 def command(cmd, *args) msg = "command: #{cmd} #{args * ', '}" log_str = "=> #{msg}" NOT_IMPORTANT_COMMANDS.include?(cmd) ? debug(log_str) : info(log_str) start_at = Time.now cmd = cmd.to_sym res = case cmd when :start, :stop, :restart, :unmonitor, :monitor, :break_chain send_command(cmd, *args) when :delete exclusive{ send_command(cmd, *args) } when :signal signal(*args) when :load load(*args) when :quit quit when :stop_all stop_all(*args) when :check check(*args) when :explain explain(*args) when :match match(*args) when :ping :pong when :logger_dev Eye::Logger.dev # object commands, for api when :info_data info_data(*args) when :short_data short_data(*args) when :debug_data debug_data(*args) when :history_data history_data(*args) else :unknown_command end GC.start log_str = "<= #{msg} (#{Time.now - start_at}s)" NOT_IMPORTANT_COMMANDS.include?(cmd) ? debug(log_str) : info(log_str) res end |