Search code examples
amazon-elastic-beanstalkamazon-linux-2

WSGI path doen't work with Amazon Linux 2


I'm trying to get going with Elastic Beanstalk and Amazon Linux 2. One thing I've noticed is that the WSGI path seems to be a little different.

For a Django app I would usually set <<app_name>>.wsgi.py

Instead, the new way to define it is with a namespace like this. This, however, does not seem to work from the eb config buy only from .ebextensions

<<app_name>>.wsgi:application

I feel like, I'm doing something wrong here or not getting this namespace concept? Why do I suddenly have to add a namespace?


Solution

  • Since other people may run into this issue.

    Here is the fix to my problem:

    Amazon Linux 2 uses Gunicorn as it's default webserver. Gunicorn expects a certain syntax when specifying the Path to the WSGI config. This syntax does not only include the path to the file but also the name of the exported function (or class) accepting the WSGI parameters.

    This is why you have to use the syntax above.

    There are several ways to specify the WSGI path for your project. You can do it via the AWS gui but my recommendation would be to add a Procfile to your project. My Procfile looks like this:

    web: gunicorn --bind :8000 --workers 3 --threads 2 <<my_app>>.wsgi:application