Script restarts every 24 hours Heroku

Viewed 251

I have a Telegram bot in Python but it is restarted by the same command in the worker about every 24 hours. I am using the free version dyno hours. How can I disable this reboot?

1 Answers

You cannot. You have to design your app so it works correctly across those restarts.

See docs:

Dynos are also restarted (cycled) at least once per day to help maintain the health of applications running on Heroku. Any changes to the local filesystem will be deleted. The cycling happens once every 24 hours (plus up to 216 random minutes, to prevent every dyno for an application from restarting at the same time). Manual restarts (heroku ps:restart) and releases (deploys or changing config vars) will reset this 24 hour period. Cycling happens for all dynos, including one-off dynos, so dynos will run for a maximum of 24 hours + 216 minutes.

Ideally you'd run at least two dynos for the same app at the same time for increased stability. Heroku will ensure they won't restart at the exact same time, so there will be always at least one online and responding to requests.

After receiving SIGTERM, you have 30 seconds to finish the work you are doing on existing requests before your process is killed, as explained here.

Related