[Backgroundrb-devel] worker starting twice

Jack Nutting jnutting at gmail.com
Tue Mar 13 11:06:58 EDT 2007


Hi gang,

Thanks to other help I've gotten on this list, I've got backgroundrb
up and running using postgres alongside my rails app.  I've designed
the system to have several eternally-running workers that periodically
poll the database to see if there's any work for them to do, and set
things up in the config file to make them restart quickly if any of
them should crash.  One odd thing I've noticed is that one of my
workers, with the key "mr", seems to start twice (without the first
one having completed).  I've got some logging that occurs when each
starts:

20070313-15:45:17 (5594) Starting WorkerLogger
20070313-15:45:17 (5595) In ResultsWorker
20070313-15:45:21 (5595) MbReceiver mr started.
20070313-15:45:21 (5595) Sender s started
20070313-15:45:22 (5595) MbSender ms1 started
20070313-15:45:22 (5595) MbSender ms2 started
20070313-15:45:22 (5595) Receiver r started
20070313-15:45:30 (5595) MbReceiver mr started.

The relevant chunk of backgroundrb_schedules.yml looks like this:

mb_receiver:
    :class: :mb_receiver
    :job_key: :mr
    :worker_method: :do_work
    :args:
        :sleep_time: 5
    :trigger_args: 0,10,20,30,40,50 * * * * * *

The other workers have identical trigger_args, but don't exhibit this behavior.

The do_work method just calls another method that loops forever, and I
wrapped that call in an exception handler to see if it was crapping
out or something, but it doesn't seem to be.  FWIW, here's the
backgroundrb_server.log from the same period of time:

20070313-15:45:17 (5594) Starting BackgrounDRb Server
20070313-15:45:17 (5594) acl: denyallallowlocalhost 127.0.0.1orderdeny allow
20070313-15:45:17 (5594) temp_dir: /tmp
20070313-15:45:17 (5594) port: 2000
20070313-15:45:17 (5594) worker_dir: /Users/jnutting/work/m_project/lib/workers
20070313-15:45:17 (5594) protocol: drbunix
20070313-15:45:17 (5594) uri: drbunix:///tmp/backgroundrbunix_localhost_2000
20070313-15:45:17 (5594) config:
/Users/jnutting/work/m_project/config/backgroundrb.yml
20070313-15:45:17 (5594) rails_env: development
20070313-15:45:17 (5594) socket_dir: /tmp/backgroundrb.5594
20070313-15:45:17 (5594) pool_size: 5
20070313-15:45:17 (5594) host: localhost
20070313-15:45:17 (5594) Starting worker:
BackgrounDRb::Worker::WorkerLogger backgroundrb_logger
(backgroundrb_logger) ()
20070313-15:45:17 (5594) Starting worker:
BackgrounDRb::Worker::WorkerResults backgroundrb_results
(backgroundrb_results) ()
20070313-15:45:17 (5594) Loading Worker Class File:
/Users/jnutting/work/m_project/lib/workers/mb_receiver.rb
20070313-15:45:17 (5594) Loading Worker Class File:
/Users/jnutting/work/m_project/lib/workers/mb_sender.rb
20070313-15:45:17 (5594) Loading Worker Class File:
/Users/jnutting/work/m_project/lib/workers/receiver.rb
20070313-15:45:17 (5594) Loading Worker Class File:
/Users/jnutting/work/m_project/lib/workers/sender.rb
20070313-15:45:17 (5594) Loading Sechedule:
job_keymrclassmb_receiverargssleep_time5
worker_method_argssleep_time5job_keymrclassmb_receiverargssleep_time5trigger_typecron_triggertrigger_args0,10,20,30,40,50
* * * * * *worker_methoddo_work #<BackgrounDRb::CronTrigger:0x23bf3c4>
20070313-15:45:17 (5594) Loading Sechedule:
job_keysclasssenderargssleep_time5
worker_method_argssleep_time5job_keysclasssenderargssleep_time5trigger_typecron_triggertrigger_args0,10,20,30,40,50
* * * * * *worker_methoddo_work #<BackgrounDRb::CronTrigger:0x23be960>
20070313-15:45:17 (5594) Loading Sechedule:
job_keyms1classmb_senderargssleep_time5
worker_method_argssleep_time5job_keyms1classmb_senderargssleep_time5trigger_typecron_triggertrigger_args0,10,20,30,40,50
* * * * * *worker_methoddo_work #<BackgrounDRb::CronTrigger:0x23bdf38>
20070313-15:45:17 (5594) Loading Sechedule:
job_keyms2classmb_senderargssleep_time5
worker_method_argssleep_time5job_keyms2classmb_senderargssleep_time5trigger_typecron_triggertrigger_args0,10,20,30,40,50
* * * * * *worker_methoddo_work #<BackgrounDRb::CronTrigger:0x23bd3e4>
20070313-15:45:17 (5594) Loading Sechedule:
job_keyrclassreceiverargssleep_time5
worker_method_argssleep_time5job_keyrclassreceiverargssleep_time5trigger_typecron_triggertrigger_args0,10,20,30,40,50
* * * * * *worker_methoddo_work #<BackgrounDRb::CronTrigger:0x23bc8cc>
20070313-15:45:20 (5594) Schedule triggered: #<struct
#<Class:0x4069c4>
job=#<Proc:0x01031b40@/Users/jnutting/work/m_project/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:319>,
trigger=#<BackgrounDRb::CronTrigger:0x23bf3c4 @year=nil, @day=1..31,
@cron_expr="0,10,20,30,40,50 * * * * * *", @sec=[0, 10, 20, 30, 40,
50], @wday=0..6, @min=0..59, @month=1..12, @hour=0..23>, earliest=Tue
Mar 13 15:45:20 +0100 2007, last=Tue Mar 13 15:45:20 +0100 2007>
20070313-15:45:21 (5594) Starting worker: mb_receiver mr
(mb_receiver_mr) (sleep_time5)
20070313-15:45:21 (5594) Schedule triggered: #<struct
#<Class:0x4069c4>
job=#<Proc:0x01031b40@/Users/jnutting/work/m_project/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:319>,
trigger=#<BackgrounDRb::CronTrigger:0x23be960 @year=nil, @day=1..31,
@cron_expr="0,10,20,30,40,50 * * * * * *", @sec=[0, 10, 20, 30, 40,
50], @wday=0..6, @min=0..59, @month=1..12, @hour=0..23>, earliest=Tue
Mar 13 15:45:20 +0100 2007, last=Tue Mar 13 15:45:20 +0100 2007>
20070313-15:45:21 (5594) Starting worker: sender s (sender_s) (sleep_time5)
20070313-15:45:21 (5594) Schedule triggered: #<struct
#<Class:0x4069c4>
job=#<Proc:0x01031b40@/Users/jnutting/work/m_project/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:319>,
trigger=#<BackgrounDRb::CronTrigger:0x23bdf38 @year=nil, @day=1..31,
@cron_expr="0,10,20,30,40,50 * * * * * *", @sec=[0, 10, 20, 30, 40,
50], @wday=0..6, @min=0..59, @month=1..12, @hour=0..23>, earliest=Tue
Mar 13 15:45:20 +0100 2007, last=Tue Mar 13 15:45:20 +0100 2007>
20070313-15:45:22 (5594) Starting worker: mb_sender ms1
(mb_sender_ms1) (sleep_time5)
20070313-15:45:22 (5594) Schedule triggered: #<struct
#<Class:0x4069c4>
job=#<Proc:0x01031b40@/Users/jnutting/work/m_project/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:319>,
trigger=#<BackgrounDRb::CronTrigger:0x23bd3e4 @year=nil, @day=1..31,
@cron_expr="0,10,20,30,40,50 * * * * * *", @sec=[0, 10, 20, 30, 40,
50], @wday=0..6, @min=0..59, @month=1..12, @hour=0..23>, earliest=Tue
Mar 13 15:45:20 +0100 2007, last=Tue Mar 13 15:45:20 +0100 2007>
20070313-15:45:22 (5594) Starting worker: mb_sender ms2
(mb_sender_ms2) (sleep_time5)
20070313-15:45:22 (5594) Schedule triggered: #<struct
#<Class:0x4069c4>
job=#<Proc:0x01031b40@/Users/jnutting/work/m_project/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:319>,
trigger=#<BackgrounDRb::CronTrigger:0x23bc8cc @year=nil, @day=1..31,
@cron_expr="0,10,20,30,40,50 * * * * * *", @sec=[0, 10, 20, 30, 40,
50], @wday=0..6, @min=0..59, @month=1..12, @hour=0..23>, earliest=Tue
Mar 13 15:45:20 +0100 2007, last=Tue Mar 13 15:45:20 +0100 2007>
20070313-15:45:22 (5594) Starting worker: receiver r (receiver_r) (sleep_time5)
20070313-15:45:30 (5594) Schedule triggered: #<struct
#<Class:0x4069c4>
job=#<Proc:0x01031b40@/Users/jnutting/work/m_project/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:319>,
trigger=#<BackgrounDRb::CronTrigger:0x23bf3c4 @year=nil, @day=1..31,
@cron_expr="0,10,20,30,40,50 * * * * * *", @sec=[0, 10, 20, 30, 40,
50], @wday=0..6, @min=0..59, @month=1..12, @hour=0..23>, earliest=Tue
Mar 13 15:45:30 +0100 2007, last=Tue Mar 13 15:45:30 +0100 2007>

Any ideas?

-- 
// jack
// http://www.nuthole.com


More information about the Backgroundrb-devel mailing list