Scheduling a Delay Job on Heroku with a Worker Dyno
Posted
by
user1524775
on Stack Overflow
See other posts from Stack Overflow
or by user1524775
Published on 2012-12-12T17:02:36Z
Indexed on
2012/12/12
17:03 UTC
Read the original article
Hit count: 188
I'm currently using Heroku's scheduler to run a script. However, the time that the script takes to run is going to increase from a few milliseconds to a few minutes. I'm looking at using the delayed_job gem to push this process off to a Worker Dyno. I want to continue to run this script once-a-day, just offload it to the worker. My current rake task is:
desc "This task updates some stuff for you."
task :update_some_stuff => :environment do
puts "Updating some stuff ..."
SomeClass.new.process
puts "... done."
end
Once the gem is installed, migration run, and worker dyno started, will the script just need to change to:
desc "This task updates some stuff for you."
task :update_some_stuff => :environment do
puts "Updating some stuff ..."
SomeClass.new.delay.process
puts "... done."
end
With this task still being a rake task scheduled by Heroku's Scheduler, is the only thing that needs to happen here the introduction of the delay
method to put this in the Worker's queue?
Thanks in advance for any help.
© Stack Overflow or respective owner