Question

I'm trying to run a deamon process running on heroku.

The framework-less app is just a ruby script which after being launched monitors my twitter stream and if there is a tweet with a photo then publish it on a tumblr.

Locally it runs just fine, but when I run it on heroku it just crashes right away.

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

I'm kind of a newbie with ruby and heroku and I'm missing something here, any help is really appreciated.

Thank you

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top