Schedule Heroku to restart dynos every 10 or so minutes

Viewed 8103

I am developing a REST api with Node.js on Heroku, and one the drivers is giving me problems (I reported that to the driver creator already), but basically a restart of the dynos every half an hour or so seems to fix this. I was hoping y'all could help me with writing a script for scheduler or something similar to restart the dynos automatically every 10 or so minutes as a temporary fix.

p.s. I checked out the scheduler documentation, but it didn't make much sense

Thanks!

2 Answers

The steps provided by @rdegges require additional authentication token in the request. Adding more details:

  1. Create Auth Token using Heroku CLI by running this command as mentioned on Heroku platform API

    heroku authorizations:create

  2. Install the Heroku Scheduler add-on into your Heroku application.

  3. Open scheduler and go to add job. Enter the following command in the job editor. This command performs restart the dyno.

`

curl -n -X DELETE https://api.heroku.com/apps/APP_NAME/dynos \n -H "Content-Type: application/json" \n -H "Accept: application/vnd.heroku+json; version=3" \n -H "Authorization: Bearer TokenCreatedInStep1"

Verify in the Heroku app logs, if the scheduler job is running on the set time.

Related