Docker/Flask/Gunicorn app continues to boot workers indefinitely

I’m attempting to create a Docker/Flask/Gunicorn app, but I can’t seem to get the PR service running (id: srv-c7ng1vjvog4uj72iscjg).

Here are the logs:

Jan 25 04:35:59 PM  Pushing image to registry...
Jan 25 04:36:08 PM  DONE
Jan 25 04:36:17 PM  [2022-01-25 21:36:17 +0000] [8] [INFO] Starting gunicorn 20.0.4
Jan 25 04:36:17 PM  [2022-01-25 21:36:17 +0000] [8] [INFO] Listening at: http://0.0.0.0:10000 (8)
Jan 25 04:36:17 PM  [2022-01-25 21:36:17 +0000] [8] [INFO] Using worker: sync
Jan 25 04:36:17 PM  [2022-01-25 21:36:17 +0000] [10] [INFO] Booting worker with pid: 10
Jan 25 04:36:24 PM  [2022-01-25 21:36:24 +0000] [26] [INFO] Booting worker with pid: 26
Jan 25 04:36:32 PM  [2022-01-25 21:36:32 +0000] [42] [INFO] Booting worker with pid: 42
Jan 25 04:36:39 PM  [2022-01-25 21:36:39 +0000] [58] [INFO] Booting worker with pid: 58
Jan 25 04:36:47 PM  [2022-01-25 21:36:47 +0000] [74] [INFO] Booting worker with pid: 74
Jan 25 04:36:54 PM  [2022-01-25 21:36:54 +0000] [90] [INFO] Booting worker with pid: 90
Jan 25 04:37:02 PM  [2022-01-25 21:37:02 +0000] [106] [INFO] Booting worker with pid: 106
...

It continues to boot workers indefinitely, but without any signs of crashing or other errors. Trying to visit this PR service url just spins and times out.

I’ve defined my PORT environment variable as 10000 as was the cause of this issue, which superficially looks similar.

I’ve also made sure my health check endpoint exists and should return a 200 response, which it does locally, as was the issue here, which also seemed superficially similar.

In my Dockerfile I define a few env variables:

ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
ENV FLASK_ENV=production 

and further down my CMD:

CMD gunicorn app:app

And finally, in my app.py:

if __name__ == '__main__':
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)

Do you have any ideas why this might not be working? Any help is appreciated.

Hi @Mitch_Kuchenberg,

It looks like you were able to get the service running - did you still need any assistance here?

All set. I was able to fix it by upgrading my plan on the app from Starter to Pro. Looks like this was a memory issue. Thank you.

Some feedback: documentation for getting a basic Docker/Flask/Gunicorn app up and running would be helpful for people encountering my use case, with additional notes for behavior you might see if you’re attempting to use large files that max out the worker memory.

Hi @Mitch_Kuchenberg,

Thanks for the feedback! We’ll definitely keep that in mind as we are looking to improve our documentation and examples.