Available from uWSGI 1.9.17.
Generally you use UNIX signals to manage the master, but we are running out of signal numbers and (more importantly) not needing to mess with PIDs greatly simplifies the implementation of external management scripts.
So, instead of signals, you can tell the master to create a UNIX named pipe (FIFO) that you may use to issue commands to the master.
To create a FIFO just add --master-fifo <filename> then start issuing commands to it.
echo r > /tmp/yourfifo
You can send multiple commands in one shot.
# add 3 workers and print stats
echo +++s > /tmp/yourfifo
uWSGI supports up to 10 different FIFO files. By default the first specified is bound (mapped as ‘0’).
During the instance’s lifetime you can change from one FIFO to another by simply sending the number of the FIFO slot to use.
[uwsgi]
master-fifo = /tmp/fifo0
master-fifo = /tmp/fifo1
master-fifo = /var/run/foofifo
processes = 2
...
By default /tmp/fifo0 will be allocated, but after sending:
echo 1 > /tmp/fifo0
the /tmp/fifo1 file will be bound.
This is very useful to map FIFO files to specific instance when you (ab)use the ‘fork the master’ command (the ‘f’ one).
echo 1fp > /tmp/fifo0
After sending this command, a new uWSGI instance (inheriting all of the bound sockets) will be spawned, the old one will be put in “paused” mode (the ‘p’ command).
As we have sent the ‘1’ command before ‘f’ and ‘p’ the old instance will now accept commands on /tmp/fifo1 (the slot 1), and the new one will use the default one (‘0’).
There are lot of tricks you can accomplish, and lots of ways to abuse the forking of the master.
Just take into account that corner-case problems can occur all over the place, especially if you use the most complex features of uWSGI.