Search code examples
pythonherokugunicornfalconframework

Falcon app using Gunicorn on Heroku stalls


I am trying to serve a falcon app on Heroku using gunicorn.

I pretty much followed the falcon docs and created a basic application.

I am using psycopg2 to add a connection cursor to each Resource when processing requests.

web: gunicorn app:api --log-level=DEBUG --worker-class=gevent

But right now every request results in a timeout:

Feb 06 18:10:01 d.19db00e4-faf8-47bc-aaea-c78a52163a24 heroku/router:  at=error code=H12 desc="Request timeout" method=GET path="/" host=falcon-raptor-api.herokuapp.com request_id=3b29350f-8990-430c-92e8-02458d91a2f9 fwd="54.91.242.125" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 

I think this is an issue with psycopg2 or gunicorn or both.

Any advice?


Solution

  • I had a similar issue deploying a Falcon API with Gunicorn on Heroku. My issue was that I was not using Gunicorn's bind argument, so there was no socket to listen to. Heroku uses dynamic port numbers, so it's best to just use the $PORT var. Try something like this in your Procfile:

    web: gunicorn -b 0.0.0.0:$PORT app:api --log-level=DEBUG --worker-class=gevent