1

我正在尝试运行在 heroku 上运行的守护进程。

无框架的应用程序只是一个 ruby​​ 脚本,它在启动后会监控我的 Twitter 流,如果有带有照片的推文,则将其发布到 tumblr。

在本地它运行得很好,但是当我在 heroku 上运行它时它会立即崩溃。

heroku[worker.1]: Starting process with command `bundle exec ruby twitter-to-tumblr.rb start`
heroku[worker.1]: State changed from starting to up
heroku[worker.1]: Process exited with status 0
heroku[worker.1]: State changed from up to crashed

我是 ruby​​ 和 heroku 的新手,我在这里遗漏了一些东西,非常感谢任何帮助。

谢谢

4

1 回答 1

0

You need to ensure that that parent process doesn't exit. Your code is most likely forking a daemon with a PID and then the parent process exits with status 0. A status of 0 means the program is finished and everything is OK. Heroku only knows that the process you asked it do finished and If you keep the parent process around it should work. The parent can then also handle signal processing for the child.

Based on your procfile command I'm guessing you are using the 'daemons' gem to handle the daemonization. You can keep the parent running by passing in the ontop option to the run command. This prevents the parent from exiting:

 Daemons.run_proc('tweetzilla', {:ontop => true}) do
   # => long running code here.
 end
于 2013-10-24T15:49:54.347 回答