Tuesday, February 1, 2022

[SOLVED] How to tell a systemd initiated uWSGI daemon to use a specific python?

Issue

I cobbled together the below uWSGI configuration file from examples online. (◠﹏◠)

Given this configuration -- which resides in /etc/uwsgi.d/myapp.ini and which is used to start the uwsgi daemon and, in turn, myapp via systemd/systemctl -- which configuration directive do I use to tell it to use a specific virtual-environment PYTHON for myapp?

Is it home =?

In other words, when it invokes the django.wsgi application, how can I tell it (or how does it know) to use: /home/myapp_unixHome/.virtualenvs/myapp/bin/python?

[uwsgi]

# =======================================================
# Directories ...
# =======================================================
home       =    /home/myapp_unixHome/.virtualenvs/myapp/  <--- Python virtualenv dir.
chdir      =    /home/myapp_unixHome/myapp/               <--- Django App here.
wsgi-file  =    /home/myapp_unixHome/myapp/django.wsgi    <--- Including this django.wsgi file.
static-map = /m=/home/myapp_unixHome/myapp/static/        <--- Static files.
# =======================================================

# =======================================================
# TO BE NAMED ...
# =======================================================
master = true
processes = 5
# =======================================================

# =======================================================
# myapp communicates w/ nginx via a UNIX domain socket.
# =======================================================
socket       = /run/uwsgi/myapp.sock
chmod-socket = 664
uid          = nginx
gid          = nginx
vacuum       = true
# =======================================================

# =======================================================
# uWSGI Log file.
# =======================================================
logto = /var/log/uwsgi.log
# =======================================================

Thank you.


Solution

Yes, check in this link http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

home            = /path/to/virtualenv

I hope it helps



Answered By - gautamaggarwal
Answer Checked By - Marie Seifert (WPSolving Admin)