Module: Ruote::Beanstalk

Defined in:
lib/ruote/beanstalk/fork.rb,
lib/ruote/beanstalk/storage.rb,
lib/ruote/beanstalk/version.rb,
lib/ruote/beanstalk/receiver.rb,
lib/ruote/beanstalk/participant_proxy.rb

Defined Under Namespace

Classes: ParticipantProxy, ReceiveError, Receiver, Storage, StorageError

Constant Summary collapse

OPT_KEYS =
{ :address => 'l', :port => 'p', :binlog => 'b', :user => 'u' }
VERSION =
'2.2.0'

Class Method Summary collapse

Class Method Details

.fork(opts = {}) ⇒ Object

:address :port :binlog :user



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ruote/beanstalk/fork.rb', line 36

def self.fork(opts={})

  quiet = opts.delete(:quiet)
  no_kill = opts.delete(:no_kill_at_exit)

  opts = opts.inject([]) { |a, (k, v)| a << "-#{OPT_KEYS[k]} #{v}" }.join(' ')

  cpid = Process.fork do
    puts "beanstalkd #{opts}" unless quiet
    exec "beanstalkd #{opts}"
  end

  unless no_kill
    at_exit { Process.kill(9, cpid) }
  end

  cpid
end