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:
- 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
. - Add a script that runs the command from point 1, e.g. you can use the platform API or
heroku run -r production scrape
. - Call the script in point 2 from the Heroku scheduler.
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
Why Should @@Class_Variables Be Avoided in Ruby
Why Use Gemspec + Gemfile When Checking for Dependencies
How to Wait for System Command to End
Ruby: Class C Includes Module M; Including Module N in M Does Not Affect C. What Gives
Difference Between Render and Yield in Rails
How to "Break" Out of a Case...While in Ruby
Timeout When Installing Ruby Gems
Private Messages with Faye and Rails
Why Slicing The Params Hash Poses a Security Issue on Mass-Assignment
Best Way to Create a Blog with Static Pages in Ruby
Why Do Ruby People Say They Don't Need Interfaces
Bundler Using Wrong Ruby Version
Ruby Readline Fails If Process Started with Arguments
How to Test If a Value Is a Prime Number in Ruby? Both The Easy and The Hard Way
How to Run Capybara-Webkit (I.E. Forked Webkit_Server) on Heroku Cedar