Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

480
Views
Export DJANGO_SETTINGS_MODULE as environment variable in supervisor

My project is based on Django, Nginx, Gunicorn and Supervisor in a Virtual env.

I export environmental variables at the end of the ./bin/activate script. Whenever I source the activate file, it exports environmental variables. It's pretty cool...

My issue comes when I start the Supervisor script. It seems that the ./bin/activate isn't sourced as Django can't get vars such as SECRET_KEY.

I heard people using a post-activate script which isn't present in my virtualenv bin dir. Am I missing something important? Why Supervisor doesn't source the ./bin/activate script?

Here is my supervisor conf:

command=/opt/.virtualenvs/plcweb/bin/gunicorn plcweb.config.wsgi -c /opt/plcweb/gunicorn.conf.py
directory=/opt/plcweb/project
user=bastien
autostart=true
autorestart=true
redirect_stderr=True
stdout_logfile=/opt/plcweb/gunicorn.log
stderr_logfile=/opt/plcweb/gunicorn.log
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

As explained here, you have a very simple solution with the environment directive. So to export DJANGO_SETTINGS_MODULE, supervisor conf file should be as following:

command=/opt/.virtualenvs/plcweb/bin/gunicorn plcweb.config.wsgi -c /opt/plcweb/gunicorn.conf.py
environment=DJANGO_SETTINGS_MODULE=my_project.settings.production
directory=/opt/plcweb/project
user=bastien
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!