简体   繁体   English

Heroku:当您的测功机/工作人员崩溃时该怎么办?

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

I have a worker doing some processing 24/7.我有一名工人 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 doing 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. Heroku 应该在每次崩溃时重新启动工作人员。 As far as I know, you don't have to select or configure anything.据我所知,您不必 select 或配置任何东西。 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.如果您严重依赖 web 应用程序中的后台作业。 You could create a rake task that finds the last record to be updated and execute a background job to update it.您可以创建一个 rake 任务来查找要更新的最后一条记录并执行后台作业来更新它。 Or perhaps automate the rake task to find the rest of the records that need updating, since the last crash.或者也许自动执行 rake 任务以查找自上次崩溃以来需要更新的记录的 rest。

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 .顺便说一下,试试1.9 stack Make sure your app is 1.9.2 compatible, before doing so.在执行此操作之前,请确保您的应用与 1.9.2 兼容。 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.最好联系 Heroku 支持。 They are very responsive at what they do.他们对他们所做的事情非常敏感。

Latest command to restart a specific heroku web worker (2014):重新启动特定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 heroku 重启 web.1

It worked for me.它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM