Hi guys: just got into Rails about a month ago and an about to launch
something.
I use Heroku and they limit the execution time of pages to 30 seconds. i
have a process which takes a lot longer than that. So i'm trying to do a
delayed job.
The docs on delayed job must be for the pros out there cause I can't
seem to find out the answers to a few simple questions..
- where do i put the file with the job in it
- what do i name it
- how do i call it
- how do I put it in the queue
- can I run it say, every 5 minutes?
Anyways, hope someone out there can help me out...
Hi guys: just got into Rails about a month ago and an about to launch
something.
I use Heroku and they limit the execution time of pages to 30 seconds. i
have a process which takes a lot longer than that. So i'm trying to do a
delayed job.
The docs on delayed job must be for the pros out there cause I can't
seem to find out the answers to a few simple questions..
- where do i put the file with the job in it
- what do i name it
- how do i call it
- how do I put it in the queue
- can I run it say, every 5 minutes?
Anyways, hope someone out there can help me out...
Thanks...Chris
This railscast should answer your first few questions -
I'm using DJ on Heroku and I'm running jobs in a recurring fashion. I
kick things off from the console. I just call some methods that I wrote
that do nothing but enqueue some jobs. I have the recurring jobs
re-enqueue themselves upon completion. Here's an example:
def enqueue_media_cleanup
#this is what I run from the Heroku console
Delayed::Job.enqueue ClearOldEventsJob.new(), 0, 15.minutes.from_now
Delayed::Job.enqueue DumpOldMediaJob.new(), 0, 2.minutes.from_now
end
def purge_expired_events
#some code to do some stuff...
#ClearOldEventsJob just runs/calls purge_expired_events
Delayed::Job.enqueue ClearOldEventsJob.new(), 0, 6.hours.from_now
end
There are other ways to do it but this has been working well for me.