Heroku进程以状态0退出,但是其dyno仍然“崩溃". [英] Heroku process exits with status 0 but its dyno still "crashes"

查看:86
本文介绍了Heroku进程以状态0退出,但是其dyno仍然“崩溃".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用红宝石编写的剪贴脚本,该脚本在工人dyno内部的heroku上运行.即使脚本运行平稳并以状态0退出,heroku仍然告诉我dyno崩溃了:

I have a scrapping script written in ruby running on heroku inside a worker dyno. Even though the script runs smoothly and exits with status 0, heroku still tells me that the dyno crashed:

2016-12-13T00:59:10.695566+00:00 heroku[spider.1]: State changed from up to crashed
2016-12-13T00:59:10.683166+00:00 heroku[spider.1]: Process exited with status 0

如何在脚本结束时使测功机正确停止?

What can I do to make the dyno stop correctly when the script ends?

谢谢.

推荐答案

作为您的dyno编队的一部分运行的Dynos预计将连续运行.适用于您的架构是:

Dynos that run as a part of your dyno formation are expected to be running continuously. The architecture that should work for you is:

  1. 以命令的形式(例如设置了可执行位的脚本)添加刮板,您可以通过heroku run运行该刮板,例如heroku run -r production scrape.
  2. 添加一个脚本,该脚本从第1点开始运行该命令,例如您可以使用平台API heroku run -r production scrape.
  3. 从Heroku调度程序中调用第2点中的脚本.
  1. Add the scraper in form of a command (e.g. a script with the executable bit set) that you'll be able to run via heroku run, e.g. heroku run -r production scrape.
  2. Add a script that runs the command from point 1, e.g. you can use the platform API or heroku run -r production scrape.
  3. Call the script in point 2 from the Heroku scheduler.

这应该是一个很好的起点.在某些极端情况下,您需要处理,例如确保一次只能刮擦一次(当然这是您的要求).

This should be a good starting point. There are some corner cases you need to handle like ensuring that only one scrape can be run at a time (if that's your requirement of course).

这篇关于Heroku进程以状态0退出,但是其dyno仍然“崩溃".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆