Reputation: 1648
While using resque-scheduler to set_schedule dynamic cron jobs based on user's input the schedules seem to be set but the worker never actually starts at the set schedule.
In the Resque configuration dynamic is set to true like so: Resque::Scheduler.dynamic = true And I am setting the schedule like so:
name = business.name + '_employee_import'
config = {}
config[:class] = 'ImporterWorker'
config[:args] = business.id.to_s
config[:cron] = cron_converter
config[:persist] = true
Resque.set_schedule(name, config)
If I do in the command line:
Resque.get_schedule("business_employee_import")
I get:
{"class"=>"MyWorker", "args"=>"87", "cron"=>"19 18 * * * *"}
But come 6:19pm the worker does not start. I have a worker running but the job never gets picked up and I have no idea why or how to troubleshoot. It seems to me this should work. I have also tried updating resque-scheduler to the latest release, no luck yet.
Thanks for any help in advanced.
Upvotes: 1
Views: 2352
Reputation: 1648
I actually solved my issue by using the following commands:
bundle exec rake environment resque:work bundle exec rake resque:scheduler
Turns out by not using Bundle Exec the schedule would not get picked up. I have not tried the environment variable command up there, but I will tomorrow and if that works out I'll give you the points.
Upvotes: 2
Reputation: 171
You probably forgot to start the scheduler with the DYNAMIC_SCHEDULE
environment variable set to true
.
Here is the command I use to start the scheduler:
DYNAMIC_SCHEDULE=true rake resque:scheduler
Quote from README:
DYNAMIC_SCHEDULE - Enables dynamic scheduling if non-empty (default false)
Upvotes: 6
Reputation: 4524
Make sure you have queue task running. So your scheduled task will get picked up by the queue.
QUEUE=* rake resque:work
Set the cron job and try again after issuing that command
Upvotes: 0