问题原文
原帖链接 · hsfzxjy · CC BY-SA 3.0
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?
已采纳解答
原帖链接 · Věroš K. · CC BY-SA 3.0
You are using
Type=Notify
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
Type=simple
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
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
