On May 19, 7:06 pm, Yuri Niyazov <[email protected]> wrote:
> If I have a worker executing a long-running job, and "herokuworkers
> 0" is executed, is that a signal to die immediately, or die after the
> current task?

I know this was posted a while back but I had the same question and
wanted to get the answer from the source (the Heroku folks). Thought I
would post the answer here so nobody else needs to bug them about the
same questions. According to the Heroku folk "It is immediately sent a
SIGTERM followed a few seconds later by a SIGKILL".

Now looking at the Delayed::Job source I see
http://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/worker.rb#L72
which indicates that if DelayedJob gets a SIGTERM it will mark a flag
to indicate it is exiting allowing the current job to finish running
before exiting. But since Heroku follows it up with a SIGKILL a few
second later this protection in DelayedJob will only help you if your
tasks are small. If it takes a while to run a task (more than a few
seconds) then your task is very likely to be killed while being
processed.

So my next question is what happens to a task that is killed mid-
process? Since DelayedJob did not get a chance to mark that task as
failed and reschedule I think DelayedJob will assume it is still
running when a worker starts back up. This means it will not try again
until the max_run_time has kicked in.

At least that is my interpretation of the events as I see them.

Eric

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to