Search code examples
herokurestart

Auto restart crashed heroku app


My app sometimes crashes and I would like to know if there is a Add-on or Dyno that I can deploy which will detect when my app is crashed and restart is automatically.


Solution

  • There's no add-on which will auto-deploy your crashed app on heroku, but here's a work around.

    • Use a log-management add-on(like papertrail)
    • Watch out for log messages you get when your heroku app crashes.
    • Add custom web-hooks that gets triggered whenever you app gives one of those error-logs that correspond to an app crash.
    • Make these web-hooks to call a custom service that redeploys your application. https://help.papertrailapp.com/kb/how-it-works/web-hooks/

    When you encounter an "app crash" situation, it usually means only the "web dyno" is crashed. Your service workers might still be running. Though this approach answers your query, I would recommend not to use it in practice because you would want to manually see you logs, find the reason for app-crash and fix it so you don't have to face it in future.