Class: Resque::Ranger

Inherits:
Object
  • Object
show all
Includes:
Raemon::Worker
Defined in:
lib/resque/ranger.rb

Instance Method Summary collapse

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/resque/ranger.rb', line 15

def run
  queues = Choice.choices[:queue].to_s.split(',')
  
  begin
    worker = Runner.new(*queues)
    worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
    worker.very_verbose = ENV['VVERBOSE']
  rescue Resque::NoQueueError
    abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
  end

  puts "*** Starting worker #{worker}"

  worker.work(ENV['INTERVAL'] || 5) # interval, will block
end

#startObject



5
6
7
# File 'lib/resque/ranger.rb', line 5

def start
  logger.info "=> Starting worker #{Process.pid}"
end

#stopObject



9
10
11
12
13
# File 'lib/resque/ranger.rb', line 9

def stop
  logger.info "=> Stopping worker #{Process.pid}"

  EM.stop_event_loop if EM.reactor_running?
end