How to run auto restart in heroku for ruby scripts

734 Views Asked by At

In my Dev box on Nitrous, I am able to run God -c scripts.god -D to restart the two .rb files if they die.

I just run that and the processes for the most part stay alive.

But I cannot do the same in heroku. It seems when I run the god command the .god file does not open and generates an error in heroku.

Question:

How can I run God to restart failed processes in heroku as I do on my development Nitrous environment?

Or is there a recommended alternative way to watch heroku processes and restart them automatically when they fail?

2

There are 2 best solutions below

4
Nathan Lee On BEST ANSWER

On Heroku you shouldn't need to use a process supervisor like god. If all you need is to ensure your process is restarted if it crashes, Heroku can manage that fine.

It should be as simple as adding two entries in your procfile as workers. https://devcenter.heroku.com/articles/background-jobs-queueing

worker: bundle exec sidekiq clock: bundle exec clockwork lib/clock.rb slack_listener: bundle exec ruby lib/slack_bot.rb

You could possibly have issues, if your processing are crashing quite often. Dyno Crash Restart Policy

1
maniacalrobot On

Your processes should start automatically when you access your website.

However, Heroku does provide commands to manage your processes, check out https://devcenter.heroku.com/articles/dynos for the complete list. E.g., to restart all processes, use the toolbelt command:

heroku ps:restart --app yourappname