Search code examples
djangolinuxcentosuwsgi

How to setup uWSGI vassal names for better log reference?


INFO:

Framweork: Django 2.X < 3.x ;
Services: supervisord; uWSGI
Host: CentOS Linux 7


Hello, i am currently testing how to deploy multiple django apps with uWSGI on my host. I set everything up based on manuals provided by my Host & uWsgi and it works. However i would like to customized everything a bit further, so that i can understand everything a bit better.

As far as i understand my uWSGI service uwsgi.ini currently works in an emperor mode and provides vassals for my two different app named baron_app.ini and prince_app.ini to handle my different apps.


Question

I noticed that the err.log is a kind of confusing for debugging with multiple apps. for instance...

announcing my loyalty to the Emperor...
Sat May  2 21:37:58 2020 - [emperor] vassal baron_app.ini is now loyal....
[pid: 26852|app: 0|req: 2/2].....

Question: Is there a way to give my vassals a name so that it will printed in the Log ? Or a way to tell uWSGI to set some kind of process & app log relation (Emperor - Vassals - Worker etc.) in the Log?

For instance i could imagine something like this, could be easier when it comes to find errors.

#baron_app:  announcing my loyalty to the Emperor...
#emperor:    Sat May  2 21:37:58 2020 - [emperor] vassal baron_app.ini is now loyal....
#prince_app: [pid: 26852|app: 0|req: 2/2].....

i tried something like procname-prefix and vassal_name but it seems not to work - maybe because i don´t know where to put it, in the uwsgi.ini or vassals*.ini?

my current settings...


...< etc < services.d < uwsgi.ini**

[program:uwsgi]
command=uwsgi --master --  %(ENV_HOME)s/uwsgi/apps-enabled 
autostart=true
autorestart=true
stderr_logfile = ~/uwsgi/err.log
stdout_logfile = ~/uwsgi/out.log
stopsignal=INT

vacuum = 1

...< uwsgi < apps-enabled < baron_app.ini**

[uwsgi] 
base = /home/kiowa/baron_app/baron_app
chdir = /home/kiowa/baron_app/
static_files = /home/kiowa/baron_app/

http = :8080
master = true
wsgi-file = %(base)/wsgi.py
touch-reload = %(wsgi-file)
static-map = /static=%(static_files)/static_storage/production_static

enable-threads = true
single-interpreter = true

app = wsgi

virtualenv = /home/kiowa/.local/env_baron

plugin = python

uid = kiowa
gid = kiowa

...< uwsgi < apps-enabled < baron_app.ini**

[uwsgi] 
base = /home/kiowa/prince_app/baron_app
chdir = /home/kiowa/prince_app/
static_files = /home/kiowa/prince_app/

http = :8000
master = true
wsgi-file = %(base)/wsgi.py
touch-reload = %(wsgi-file)
static-map = /static=%(static_files)/static_storage/production_static

enable-threads = true
single-interpreter = true

app = wsgi

virtualenv = /home/kiowa/.local/prince_app

plugin = python

uid = kiowa
gid = kiowa

Solution

  • Ok i was able to seperate my vassals log files by putting this into my vassals.ini

    ; set app / error Log - check
    logger = file:%(var_logs)/vassal_baron/baron_app.log
    
    ; disable default req log and set request Log and - check
    req-logger = file:%(var_logs)/vassal_baron/baron_request.log
    disable-logging = true