Class: CouchLoafer::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/couch_loafer/worker.rb

Constant Summary collapse

SLEEP =
5

Instance Method Summary collapse

Instance Method Details

#say(text) ⇒ Object



26
27
28
29
# File 'lib/couch_loafer/worker.rb', line 26

def say(text)
  puts text unless @quiet
  logger.info text if logger
end

#single_runObject



22
23
24
# File 'lib/couch_loafer/worker.rb', line 22

def single_run
  CouchLoafer::Job.work_off
end

#startObject



12
13
14
15
16
17
18
19
20
# File 'lib/couch_loafer/worker.rb', line 12

def start
  trap('TERM') { say 'Exiting...'; $exit = true }
  trap('INT')  { say 'Exiting...'; $exit = true }
  loop do
    single_run
    break if $exit
    sleep(SLEEP)
  end
end