我已经pimd
通过apt
. 这带有上游systemd
单元文件 ( /lib/systemd/system/pimd.service
)。
我希望服务在由于某种原因被杀死时重新启动,因此我希望Restart = always
在单元文件中添加该行。
但是,我不想修改上游单元文件。
有什么解决方法吗?
我遵循了这个答案:https : //serverfault.com/a/893075/210494。我有 CentOS 7.8。
Redis服务
[Service]
Type=notify
ExecStart=/opt/redis/bin/redis-server /opt/redis/conf/redis-master.conf
TimeoutStartSec=60
TimeoutStopSec=60
TimeOutSec=90
RestartSec=5s
Restart=on-success
Run Code Online (Sandbox Code Playgroud)
redis-master.conf
daemonize no
supervised systemd
Run Code Online (Sandbox Code Playgroud)
当我运行此服务时,Redis 进程启动但systemctl
挂起,我必须按 Ctrl-C 才能返回 shell。
这是在日志中:
69486:C 28 Aug 2020 17:31:14.545 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=69486, just started
69486:C 28 Aug 2020 17:31:14.545 # Configuration loaded
69486:C 28 Aug 2020 17:31:14.545 # WARNING supervised by systemd - you MUST set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit.
69486:M 28 Aug 2020 …
Run Code Online (Sandbox Code Playgroud)