I\'m currently having difficulty passing environment variables into Gunicorn for my Django project. I\'m on the latest 19.1 version. I have a wsgi.py file like so:
I got a similar problem when deploying gunicorn.service
. And I passed environment variables to it by a file:
[Service]
...
EnvironmentFile=/pathto/somefilewith_secrets
...
For example (cat /etc/systemd/system/gunicorn.service
)
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=ubuntu
Group=ubuntu
WorkingDirectory=/home/ubuntu/10008/digichainOpen
EnvironmentFile=/home/ubuntu/10008/digichainOpen/.env
ExecStart=/home/ubuntu/.local/share/virtualenvs/digichainOpen-Zk2Jnvjv/bin/gunicorn \
--worker-class=gevent --workers 4 \
--bind unix:/home/ubuntu/10008/digichainOpen/gunicorn.sock digichainOpen.wsgi:application
[Install]
WantedBy=multi-user.target
and the .env
file can be:
my_var=someValue
some_secret=secretvalue
another_secret=blah