Module: Beanworker

Defined in:
lib/beanworker.rb,
lib/beanworker/worker.rb

Defined Under Namespace

Modules: Worker

Constant Summary collapse

VERSION =
'0.0.5'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connection_configObject

Returns the value of attribute connection_config.



11
12
13
# File 'lib/beanworker.rb', line 11

def connection_config
  @connection_config
end

Class Method Details

.run(opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/beanworker.rb', line 13

def run(opts={})
  self.connection_config = opts[:connection_host] || Beanqueue.get_params(opts[:connection_file])
  if opts[:daemonize]
    Daemons.run_proc 'beanworker', ARGV: ['start'], monitor: opts[:monitor], dir: opts[:pid_dir] do
      run_loop(opts)
    end
  else
    run_loop(opts)
  end
end

.run_loop(opts = {}) ⇒ Object



24
25
26
27
# File 'lib/beanworker.rb', line 24

def run_loop(opts={})
  require opts[:jobs_file]
  loop { gets } unless opts[:no_wait]
end