Reputation: 106
I'm trying to run a simple app on heroku. It doesn't use Flask at all, the script just needs to be run once and it will (or should) keep itself alive. It runs fine locally, it runs fine on my VPS. I really want to deploy it to heroku for the ease of maintenance/addons though. So I deployed it, made sure all the dependencies were installed, etc.
This is my Procfile:
web: newrelic-admin run-program python dragon.py
But when I try to run it, it will run fine for a few seconds before I get this error:
heroku/web.1: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
In those few seconds, it will even respond to commands (it's a chat bot), but inevitably fails with the failed to bind error. I've tried several solutions, such as adding $PORT
to my procfile, and none of them worked. I tried using gunicorn
and the app would run, but it wouldn't receive or respond to incoming commands.
I'm at a loss, does anyone know a surefire way to bind a port for a Python app NOT running Flask? I couldn't find any answers for anything that wasn't using Flask in some way, but adding Flask didn't appear to be working either. I just need this app to run as-is, but bind to a port so it will stay open.
This is a screenshot of my logs, showing the request/response headers, and even the first keepalive signal being sent by the app before it crashes.
http://puu.sh/h3Jo2/e689e9ba38.png
First edit: I contacted Heroku Support to get my boot timeout increased to 120 seconds. It still failed to bind to $PORT, despite running and working until it crashed. I also tried specifying a port in the config vars, to no avail. This is a screenshot of my logs showing failure to boot (twice) after 120 seconds: http://puu.sh/h4e4r/11c50a5ae7.png
Upvotes: 4
Views: 796
Reputation: 106
Alright, I figured it out. I contacted support again and found out that I was using the wrong process type. I am now running it as a bot
process, so my Procfile now looks like this:
bot: newrelic-admin run-program python dragon.py
This allows it to run without binding to a port.
Upvotes: 4