Restart my heroku application automatically

后端 未结 7 1565
北海茫月
北海茫月 2020-12-13 08:01

This terminal command restarts my heroku application:

heroku restart

Is there a way to run a script that will run this command and restart

7条回答
  •  心在旅途
    2020-12-13 08:40

    We solved this by using a buildpack to get the heroku command available to the dyno itself, then using Heroku Scheduler.

    We added the https://github.com/gregburek/heroku-buildpack-toolbelt buildpack per its instructions:

    heroku buildpacks:add https://github.com/gregburek/heroku-buildpack-toolbelt.git
    heroku config:add HEROKU_TOOLBELT_API_EMAIL=`heroku whoami`
    heroku config:add HEROKU_TOOLBELT_API_PASSWORD=`heroku auth:token`
    

    Then made sure the app slug was rebuilt per the instructions:

    git push heroku master
    

    In Heroku Scheduler, we added this as a hourly job:

    vendor/heroku-toolbelt/bin/heroku ps:restart -a $HEROKU_APP_NAME
    

    You can determine if it's working by looking for Scheduler output in the Heroku logs, and of course by the memory graph of the app in the Heroku dashboard (if you're restarting to work around a memory leak).

提交回复
热议问题