0

So I was fooling around the slack API and ended up making a simple slack bot which posts on a slack channel whether a site is up or not (when provided with the URL)

Whenever I deploy it to heroku, it works for the first 60 seconds and then throws an error like this in the logs

2016-06-22T20:18:11.933928+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-22T20:18:15.635404+00:00 heroku[web.1]: Starting process with command `python margo/margo.py 5000`
2016-06-22T20:18:18.724727+00:00 app[web.1]: StarterBot connected and running!
2016-06-22T20:19:15.714485+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-22T20:19:15.714485+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-06-22T20:19:16.857081+00:00 heroku[web.1]: Process exited with status 137
2016-06-22T20:19:16.874584+00:00 heroku[web.1]: State changed from starting to crashed

My Procfile looks something like this

web: python margo/margo.py 5000

I searched around and found this and this saying that the PORT should be specified at the Profile and I changed it like the above in the Procfile. But mine is just a simple python script and not a full blown Flask/Django app.

Any ideas guys where am I going wrong?

EDIT

I read up that the $PORT environment variable is set by heroku. So my Procfile is now

web: python margo/margo.py $PORT

But the program crashes again with the same error message when deployed

Community
  • 1
  • 1
Tasdik Rahman
  • 2,160
  • 1
  • 25
  • 37

1 Answers1

0

I solved this problem by running a simple HTTP server on the port provided by Heroku and made it run as a background process.

After the changes, my Procfile looks like this

web: (python -m http.server $PORT &) && (python margo/margo.py)

So, even though the web server was doing nothing, it binded itself to the port and prevented the app from crashing further.

Tasdik Rahman
  • 2,160
  • 1
  • 25
  • 37
  • Rather than the `&&` construct, I suggest a separate process line: `worker: python margo/margo.py`. You can then manage it explicitly via `heroku ps:start worker`. – bimsapi Jul 07 '16 at 20:55