问题
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
回答1:
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).
来源:https://stackoverflow.com/questions/4661608/getting-extra-rufus-scheduler-thread-with-each-delayed-job-rake-jobswork