Heroku Process Exits with Status 0 But Its Dyno Still "Crashes"

Heroku process exits with status 0 but its dyno still crashes

Dynos that run as a part of your dyno formation are expected to be running continuously. The architecture that should work for you is:

  1. Add the scraper in form of a command (e.g. a script with the executable bit set) that you'll be able to run via heroku run, e.g. heroku run -r production scrape.
  2. Add a script that runs the command from point 1, e.g. you can use the platform API or heroku run -r production scrape.
  3. Call the script in point 2 from the Heroku scheduler.

This should be a good starting point. There are some corner cases you need to handle like ensuring that only one scrape can be run at a time (if that's your requirement of course).

Heroku Node.js app keeps crashing and restarting

It was actually simpler than I thought, but the concept / types of dynos confused me. Scripts that are meant to execute and finish should not actually use any web or worker dynos, just the scheduler. The scheduler will run off of its own one-off dyno.

bot hosted on heroku keeps crashing

Looking at the logs the only time you have an actual crash has a really obvious error after it:

2017-03-07T09:14:16.588543+00:00 app[web.1]: Executing action: fetch-forecast
2017-03-07T09:14:16.717633+00:00 app[web.1]: /app/services/wit.js:149
2017-03-07T09:14:16.717635+00:00 app[web.1]: if (date === jsonData.list[i].dt_txt) {
2017-03-07T09:14:16.717636+00:00 app[web.1]: ^
2017-03-07T09:14:16.717637+00:00 app[web.1]:
2017-03-07T09:14:16.717638+00:00 app[web.1]: TypeError: Cannot read property 'dt_txt' of undefined
2017-03-07T09:14:16.717639+00:00 app[web.1]: at Request._callback (/app/services/wit.js:149:32)
2017-03-07T09:14:16.717640+00:00 app[web.1]: at Request.self.callback (/app/node_modules/request/request.js:187:22)
2017-03-07T09:14:16.717640+00:00 app[web.1]: at emitTwo (events.js:87:13)
2017-03-07T09:14:16.717641+00:00 app[web.1]: at Request.emit (events.js:172:7)
2017-03-07T09:14:16.717642+00:00 app[web.1]: at Request.<anonymous> (/app/node_modules/request/request.js:1126:10)
2017-03-07T09:14:16.717642+00:00 app[web.1]: at emitOne (events.js:77:13)
2017-03-07T09:14:16.717643+00:00 app[web.1]: at Request.emit (events.js:169:7)
2017-03-07T09:14:16.717644+00:00 app[web.1]: at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1046:12)
2017-03-07T09:14:16.717645+00:00 app[web.1]: at IncomingMessage.g (events.js:260:16)
2017-03-07T09:14:16.717646+00:00 app[web.1]: at emitNone (events.js:72:20)
2017-03-07T09:14:16.863152+00:00 heroku[web.1]: State changed from up to crashed

The rest just looks like the dyno scaling. What dyno type are you running on Heroku? If it is the free version it will go to sleep after a period of inactivity.



Related Topics



Leave a reply



Submit