Class: FrenzyBunnies::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/frenzy_bunnies/cli.rb

Constant Summary collapse

BUNNIES =
<<-EOF

  (\\___/)
  (='.'=)  Frenzy Bunnies!
  (")_(")  JRuby based workers on top of hot_bunnies

EOF

Instance Method Summary collapse

Instance Method Details

#start_workers(workerfile) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/frenzy_bunnies/cli.rb', line 14

def start_workers(workerfile)

  require workerfile
  # enumerate all workers
  workers = []
  ObjectSpace.each_object(Class){|o| workers << o if o.ancestors.map(&:name).include? "FrenzyBunnies::Worker"}
  workers.uniq!
  
  puts BUNNIES

  c = FrenzyBunnies::Context.new
  c.logger.info "Discovered #{workers.inspect}"
  c.run *workers
  Signal.trap('INT') { c.stop; exit! }
end