When using supervisor in a project, there are small problems with how to start in a virtual environment.
Tried the sh script, activating the virtual environment in the script, so that although it can start normally, supervisor cannot end the process correctly and must end manually.
After repeated groping, found that it is easy to achieve, slightly modified under the Supervisor configuration can be.
Suppose that our virtual environment is in the venv of the project root directory.
Then in the configuration of the supervisor to make the following changes, do not need to modify the place omitted.
Directory=/home/pepper/code/jadetower_health above this point to the root directory of the project Command=venv/bin/python gunicorn-w 6-b 0.0.0.0:8001 Project.wsgi--access-logfile logs/gunicorn.log Command launch commands do not use Python directly, but instead use Python in the virtual environment, this is Venv/bin/python. Finally, following the script that needs to be started, I'm using the Gunicron. Finally, update the supervisor configuration SupervisorctlUpdate and then restartSupervisorctl ReloadAt this point the project is already running in a virtual environment.
Supervisor supports Python virtual environments venv