简体   繁体   English

你知道如何让系统自动重启daemon服务吗?

[英]Do you know how to make the system automatically restart daemon service?

I have made a daemon service in linux server.我在 linux 服务器做了一个守护进程服务。 It is running well.它运行良好。 The service file is stargate.service (in /etc/systemd/system).服务文件是 stargate.service(在 /etc/systemd/system 中)。

[Unit]
Description=stargate

[Service]
Type=simple
PIDFile=/app/stargate/stargate.pid
ExecStart=/app/stargate/stargate.sh start
ExecReload=/app/stargate/stargate.sh restart
ExecStop=/app/stargate/stargate.sh stop

[Install]
Alias=stargate
WantedBy=default.target

If by some reasons, the daemon service is die and stop.如果由于某种原因,守护进程服务终止并停止。 Do you know how to make the system automatically restart the daemon service?你知道如何让系统自动重启daemon服务吗? How to make the daemon service starts if server get rebooted?如果服务器重新启动,如何使守护程序服务启动?

To respawn your service when it fails, add the following to the [Service] block:要在失败时重新生成您的服务,请将以下内容添加到[Service]块:

[Service]
Restart=on-failure
RestartSec=3

If you wish to always restart when your service is killed use Restart=always如果您希望在服务终止时始终重新启动,请使用Restart=always

The RestartSec value is the delay between restart attempts. RestartSec值是重新启动尝试之间的延迟。

See more info here: https://www.freedesktop.org/software/systemd/man/systemd.service.html在此处查看更多信息: https://www.freedesktop.org/software/systemd/man/systemd.service.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM