Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

python - Flask App on Heroku does not stop booting workers

I've been trying to deploy my Flask project (Twilio SMS bot) to Heroku, but whenever I deploy the logs show workers being booted non-stop:

2021-01-10T18:57:11.525145+00:00 app[web.1]: [2021-01-10 18:57:11 +0000] [20632] [INFO] Booting worker with pid: 20632
2021-01-10T18:57:11.902427+00:00 app[web.1]: [2021-01-10 18:57:11 +0000] [20633] [INFO] Booting worker with pid: 20633
2021-01-10T18:57:12.018448+00:00 app[web.1]: [2021-01-10 18:57:12 +0000] [20634] [INFO] Booting worker with pid: 20634
2021-01-10T18:57:12.475161+00:00 app[web.1]: [2021-01-10 18:57:12 +0000] [20635] [INFO] Booting worker with pid: 20635
2021-01-10T18:57:12.622354+00:00 app[web.1]: [2021-01-10 18:57:12 +0000] [20636] [INFO] Booting worker with pid: 20636
2021-01-10T18:57:12.945738+00:00 app[web.1]: [2021-01-10 18:57:12 +0000] [20637] [INFO] Booting worker with pid: 20637
2021-01-10T18:57:13.301953+00:00 app[web.1]: [2021-01-10 18:57:13 +0000] [20638] [INFO] Booting worker with pid: 20638
2021-01-10T18:57:13.506961+00:00 app[web.1]: [2021-01-10 18:57:13 +0000] [20639] [INFO] Booting worker with pid: 20639
2021-01-10T18:57:13.806545+00:00 app[web.1]: [2021-01-10 18:57:13 +0000] [20640] [INFO] Booting worker with pid: 20640
2021-01-10T18:57:13.912250+00:00 app[web.1]: [2021-01-10 18:57:13 +0000] [20641] [INFO] Booting worker with pid: 20641
2021-01-10T18:57:14.842376+00:00 app[web.1]: [2021-01-10 18:57:14 +0000] [20644] [INFO] Booting worker with pid: 20644
2021-01-10T18:57:15.082539+00:00 app[web.1]: [2021-01-10 18:57:15 +0000] [20645] [INFO] Booting worker with pid: 20645
2021-01-10T18:57:15.245975+00:00 app[web.1]: [2021-01-10 18:57:15 +0000] [20646] [INFO] Booting worker with pid: 20646

And when I try to boot the app, I eventually get Error 12 (timeout) after 30 seconds. Here is my Procfile:

web: gunicorn main:app

My slug size is quite large (261 MB), so I'm not sure if it has something to do with this. I've also noticed in the build logs:

ERROR: tensorflow-cpu 2.4.0 has requirement wheel~=0.35, but you'll have wheel 0.34.2 which is incompatible.

I'm not sure if this would cause an error. Everything runs properly on my local machine. Any suggestions would be appreciated – thanks in advance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Twilio developer evangelist here.

I am guessing here, but it could be that your application is not starting on the port number that Heroku is expecting it to (provided by the PORT environment variable. When Heroku doesn't detect the app started, it tries again and again until the timeout.

Following the Heroku tutorial for getting a Python application running on Heroku you should be getting the port number from the environment with something like this:

port = int(os.environ.get("PORT", 5000))

before then using it to run the app

app.run(host='0.0.0.0', port=port)

Given that error at the end, you should probably downgrade the version of wheel your application uses to match what is available on Heroku too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...