开发者

Heroku: What to do when your dyno/worker crashes?

I have a worker doing some processing 24/7. However, sometimes the code crashes and it needs to be restarted (even if I catch the exception, I have to restart the worker in order for it to work).

What do you do when this happens or am I doin开发者_如何学JAVAg something wrong and this shouldn't happen at all? Does your dynos/workers crash or it is just me?

thanks


Heroku is supposed to restart a worker every time it crashes. As far as I know, you don't have to select or configure anything. Whatever is in your jobs:work task will be executed as soon as it fails.

In the event that you are heavily dependent on background jobs in your web app. You could create a rake task that finds the last record to be updated and execute a background job to update it. Or perhaps automate the rake task to find the rest of the records that need updating, since the last crash.

Alternatively, you force worker restart manually as indicated in this article (using delayed_job):

heroku workers 0; 
heroku workers 1;

Or perhaps you can restart a specific worker by doing (mentioned in this article):

heroku restart worker.1

By the way, try the 1.9 stack. Make sure your app is 1.9.2 compatible, before doing so. Hopefully crashes are less frequent there:

heroku stack:migrate bamboo-mri-1.9.2

In the event, that such issues still arise. Best to contact Heroku support. They are very responsive at what they do.


Latest command to restart a specific heroku web worker (2014):

heroku ps:restart web.1

(tested on Cedar stack)


At times, for instance in case of DB crashes, the worker may not restart automatically. you would need to do this.

heroku restart web.1

It worked for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜