大网数据广告活动
服务器运维问答

Why my service restarted every 90 seconds?

· 52CE 我爱测

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.ta…

问题原文

原帖链接 · 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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。