Daphne sevice unit for systemd is not working, daphne.socket vs daphne.sevice
Hi, @andrewgodwin I am facing a problem to start daphne service by systemd on CentOS. The first question, I've got confused with daphne.socket and daphne.sevice. Is daphne.socket file necessary? Or I can run daphne service by having only daphne.sevice?
The second question, daphne.service is not running. Here my daphne.socket unit which starts successfully:
#/etc/systemd/system/daphne.socket
[Unit]
Description=Daphne Socket
[Socket]
ListenStream=0.0.0.0:80
Accept=yes
[Install]
WantedBy=sockets.target
systemctl status daphne.socket :
daphne.socket - Daphne Socket Loaded: loaded (/etc/systemd/system/daphne.socket; enabled; vendor preset: disabled) Active: active (listening) since (date) CEST; 1s ago Listen: 0.0.0.0:80 (Stream) Accepted: 1; Connected: 0
And here is my daphne.service unit:
#/etc/systemd/system/daphne.service
[Unit]
Description=daphne server script for MyProject
Requires=daphne.socket
After=syslog.target
After=network.target
After=nginx.service
[Service]
Type=simple
WorkingDirectory=/path/to/MyProject
ExecStart=path/to/venv/bin/daphne -b 0.0.0.0 -p 80 --root-path=/path/to/MyProject MyProject.asgi:channel_layer
Restart=always
StandardInput=socket
StandardError=journal
[Install]
WantedBy=multi-user.target
systemctl status daphne.service
daphne.service - daphne server script for MyProject Loaded: loaded (/etc/systemd/system/daphne.service; enabled; vendor preset: disabled) Active: failed (Result: start-limit) since (date) CEST; 3s ago Main PID: 20347 (code=exited, status=1/FAILURE)
CentOS-74-64-minimal systemd[1]: daphne.service failed to run 'start' task: Invalid argument CentOS-74-64-minimal systemd[1]: Failed to start daphne server script for MyProject CentOS-74-64-minimal systemd[1]: Unit daphne.service entered failed state. CentOS-74-64-minimal systemd[1]: daphne.service failed. CentOS-74-64-minimal systemd[1]: Starting daphne server script for MyProject... CentOS-74-64-minimal systemd[1]: daphne.service holdoff time over, scheduling restart. CentOS-74-64-minimal systemd[1]: start request repeated too quickly for daphne.service
journalctl -u daphne.service
CentOS-74-64-minimal systemd[1]: Got more than one socket.
So, anyone has any idea what is wrong here? Because I don't. Thank you so much in advance
I'm afraid I don't know too much about systemd - maybe someone else can help. Since this is not a bug in Daphne itself, though, I will close this ticket.
It is working right now. I removed the daphne.socket unit and modified the daphne.service unit. Here the daphne.service uni file:
[Unit]
Description=daphne server script
After=network.target
[Service]
WorkingDirectory=/path/to/myproject
Environment=DJANGO_SETTINGS_MODULE=myproject.settings
ExecStart=/path/to/myproject/env/bin/daphne -b 0.0.0.0 -p 8001 myproject.asgi:channel_layer
Restart=always
[Install]
WantedBy=multi-user.target
And of course: systemctl daemon-reload systemctl restart daphne.service
I my case to above works but, after some time , or after some request, Daphne stops processing the request, means i get nothing even after printing debug logs.
But as I do systemctl restart daphne.service everthing works as normal for while,
And shuts down again.
I my case to above works but, after some time , or after some request, Daphne stops processing the request, means i get nothing even after printing debug logs.
But as I do
systemctl restart daphne.serviceeverthing works as normal for while, And shuts down again.
Hi, did you found the anwer?, i can´t resolve
yes please explain what is the answer..