I have a small .py/Flask application that I can run from the command line as a uWSGI or Gunicorn Server.

Flask's site shows an abbreviated way to simply run a Flask app w/ these types of servers, i.e. esp. if I am using my source in a venv.

Do you know how to run a uWSGI server or Gunicorn server under a venv on boot?

I am basically running some simple source to test out servers for Flask applications and Python3.


Do you know how to run a uWSGI server or Gunicorn server under a venv on boot?

You have to create an virtual environment and hardcode the path to uWSGI or Gunicorn.

To start the app on boot, use systemd or supervisor.

An example of using supervisor.

# content from /etc/supervisor/conf.d/microblog.conf

command=/home/ubuntu/microblog/venv/bin/gunicorn -b localhost:8000 -w 4 microblog:app

Check Miguel's tutorial about Deployment on Linux for detail.

  • Hello...how do I "hardcode the path" to Gunicorn? – Mala Dies Sep 13 at 1:20
  • @MalaDies Hardcoding means using the absolute path of the executable file. – Simba Sep 14 at 9:14
  • Hello...Thank you for clarifying. @Simba, thank you for taking time out to reply. – Mala Dies Sep 17 at 3:09

I found a nifty way via what Simba was describing in Supervisor but w/ systemd .service files.


Description=Gunicorn Server for a Flask/Python3 Application

ExecStart=/home/debian/virt/env/bin/gunicorn -b -w 4 TheNameOfMyPythonApp:app


So, I just described my directory in the [Service] section and then used ExecStart= to give my Gunicorn location in my environment a start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.