I run Flask app using uWSGI.
I set uWSGI "Process" value is 2.
However, uWSGI starts 3 processes.
Why is this? What does the third process do?
The following is the result of executing service uwsgi status
.
● uwsgi.service - uWSGI
Loaded: loaded (/etc/systemd/system/uwsgi.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-03-02 18:00:45 JST; 3 days ago
Main PID: 26656 (uwsgi)
Status: "The Emperor is governing 1 vassals"
Tasks: 5 (limit: 1103)
CGroup: /system.slice/uwsgi.service
tq11620 /usr/local/bin/uwsgi --ini app1.ini
tq14304 /usr/local/bin/uwsgi --ini app1.ini
tq26656 /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --die-on-term --logto /var/log/uwsgi/emperor.log --logfile-chmod 640 --touch-logreopen /var/log/uwsgi/emperor.log.trigger
tq26664 /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --die-on-term --logto /var/log/uwsgi/emperor.log --logfile-chmod 640 --touch-logreopen /var/log/uwsgi/emperor.log.trigger
mq26666 /usr/local/bin/uwsgi --ini app1.ini
I found two emperor processes and three vassal processes.
The result of ps aux | grep uwsgi
is following:
user 721 0.0 1.1 58456 11356 ? Ss 11:37 0:00 /usr/local/bin uwsgi --emperor /etc/uwsgi/vassals --die-on-term --logto /var/log/uwsgi/emperor.log --logfile-chmod 640 --touch-logreopen /var/log/uwsgi/emperor.log.trigger
user 795 0.0 0.2 52424 2540 ? S 11:37 0:00 /usr/local/bin uwsgi --emperor /etc/uwsgi/vassals --die-on-term --logto /var/log/uwsgi/emperor.log --logfile-chmod 640 --touch-logreopen /var/log/uwsgi/emperor.log.trigger
user 796 0.0 5.2 168676 52608 ? S 11:37 0:02 /usr/local/bin uwsgi --ini app1.ini
user 1056 0.0 5.3 173056 53444 ? S 11:37 0:04 /usr/local/bin uwsgi --ini app1.ini
user 1057 0.0 5.3 173136 53412 ? S 11:37 0:03 /usr/local/bin uwsgi --ini app1.ini
user 2602 0.0 0.0 14428 1000 pts/1 S+ 13:22 0:00 grep --color=auto uwsgi
I use the emperor.
/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --die-on-term --logto /var/log/uwsgi/emperor.log --logfile-chmod 640 --touch-logreopen /var/log/uwsgi/emperor.log.trigger
The following is the INI file of uWSGI.
[uwsgi]
base = /home/shizai/%n
chdir = %(base)
module = webapp.view:app
master = true
processes = 2
gevent = 1024
socket = /tmp/uwsgi_%n.sock
chmod-socket = 666
vacuum = true
die-on-term = true
logto = /var/log/uwsgi/%n.log
logfile-chmod = 640
touch-logreopen = /var/log/uwsgi/%n.log.trigger
log-encoder = format ${strftime:%%Y/%%m/%%d %%H:%%M:%%S} - ${msgnl}
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true
harakiri = 90
touch-reload = .uwsgi_touch
Thank you.
It's normal behaviour: master = true
and workers = 2
will start 3 processes: 1 master and 2 workers.