Problem in a nutshell: systemd creates a socket on boot, but it is not possible to restart or recreate it without a reboot.
/etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
After reboot, /run/gunicorn.sock exists and I can connect to it with sudo gunicorn3 --bind unix:/run/gunicorn.sock test.wsgi
. But after taking that process down with Ctrl+C, the socket disappears and cannot be recreated via sudo systemctl start gunicorn.socket
. Incidentally, sudo systemctl status gunicorn.socket
still shows the socket as active and OK.
Is something wrong or are my expectations off here (I'm not yet very familiar with systemd)?
Bonus question: I've tried to make the socket owned by the www-data user by adding "User=www-data" to the [Socket] stanza of the config file, but the socket is still owned by root.root. Where's my mistake?
0 Answers