I'm working with Ubuntu Server 16.04.
Here's the .service
file:
[Unit]
Description=NoDescpt
[Service]
ExecStart=/home/git/cmd/daphnei
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
And the related script /home/git/cmd/daphnei
:
#!/bin/bash
cd /home/git/hsfzmun/server
/home/git/virtualenvs/hsfzmun/bin/daphne -b 0.0.0.0 -p 8001 -v2 config.asgi:channel_layer
What confused me is that the service will restart every 90 seconds, but I can't find out why.
I've found that the service's status is always activating
, which means systemd
doesn't know that the service has been started. However the script did start because I can visit my website. So what's wrong with it?
Best Answer
You are using
in your unit file. It means that the application should notify systemd when it is ready to server via sd-notify Systemd probably receives no notification from your app and restarts it.
Unless your application is sending notification to systemd, you should update corresponding line to
Other option is to check whether
daphne
can send notification to systemd and turn the notification on.Check systemd documentation on notify for more details on
Type=notify