Class: Smith::Commands::Start

Inherits:
Smith::CommandBase show all
Includes:
Common
Defined in:
lib/smith/commands/agency/start.rb

Instance Attribute Summary

Attributes inherited from Smith::CommandBase

#options, #target

Instance Method Summary collapse

Methods included from Common

#agent_group

Methods inherited from Smith::CommandBase

#banner, #format_help, #initialize, #parse_options

Methods included from Logger

included

Constructor Details

This class inherits a constructor from Smith::CommandBase

Instance Method Details

#executeObject



11
12
13
14
15
# File 'lib/smith/commands/agency/start.rb', line 11

def execute
  start do |value|
    responder.succeed(value)
  end
end

#start(&blk) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/smith/commands/agency/start.rb', line 17

def start(&blk)
  #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  #!!!!!!!!!!!! See note about target at end of this file !!!!!!!!!!!!!
  #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  # Sort out any groups. If the group option is set it will override
  # any other specified agents.
  if options[:group]
    begin
      agents_to_start = agent_group(options[:group])
      if agents_to_start.empty?
        blk.call("Agent group is empty. No agents started: #{options[:group]}")
      else
        start_agents(agents_to_start, &blk)
      end
    rescue RuntimeError => e
      blk.call(e.message)
    end
  else
    start_agents(target, &blk)
  end
end