pmneve
pmneve

Reputation: 616

Getting extra rufus-scheduler thread with each delayed_job rake jobs:work

Am trying to use rufus-scheduler to check every minute or so to see if there are jobs ready to be placed in the delayed_job queue.

Have an initializer script in #{RAILS_ROOT}/config/initializers that starts the scheduler. Unfortunately the rake jobs:work also runs the rails initialization process so another gets started for each jobs:work started.

How can I prevent this?

Running ruby 1.8.6.26, rails 2.3.5, dj 1.8.5, rufus-scheduler 2.0.6 on XP pro sp3

Upvotes: 0

Views: 855

Answers (1)

jmettraux
jmettraux

Reputation: 3551

In your initializer, find a way not to run the schedule if the rails initialization process is invoked via Rake.

For sure there is a more railsy way, but you could do

  unless defined?(Rake)
    # do the scheduling...
  end

The block 'do the scheduling' won't get called if the constant Rake is defined (for a Rake task it is defined).

Upvotes: 4

Related Questions