I'm trying to run daphne
2.1 using multiprocessing. In the documentation I have:
If you want to bind multiple Daphne instances to the same port on a machine, use a process supervisor that can listen on ports and pass the file descriptors to launched processes, and then pass the file descriptor with --fd NUM.
I tried to this with a socket (dapnhe.socket
):
[Unit]
Description=Daphne Socket worker %i
[Socket]
ListenStream=/usr/local/reduction/dist/daphne.sock
Accept=yes
[Install]
WantedBy=sockets.target
And with a service (daphne@.service
)
[Unit]
Description=Daphne Service For Django %I
After=syslog.target
Requires=daphne.socket
[Service]
Type=simple
RuntimeDirectory=daphne
PIDFile=/run/daphne.pid
WorkingDirectory=/usr/local/reduction/src
ExecStartPre=/bin/bash -c 'systemctl set-environment FD=`echo %i | tr -d -`'
ExecStart=/bin/bash -c '/usr/local/reduction/venv/bin/daphne -fd ${FD} server.asgi:application'
Restart=always
[Install]
WantedBy=multi-user.target
The %i
has the form %d-%d-%d
. I'm just removing the -
before passing it to daphne
.
This doesn't work...
Anyone knows how to pass an FD to daphne
?