一个服务(例如 bar.service)依赖于另一个服务(例如 foo.service),如下所示
酒吧的服务文件:
[Unit]
After=foo.service
Requires=foo.service
...
如果 foo.service 重新启动(手动或由于错误),bar.service 如何自动重新启动?
最佳答案
您可以使用 PartOf
。
[Unit]
After=foo.service
Requires=foo.service
PartOf=foo.service
来自 systemd.unit
手册页:
PartOf=
Configures dependencies similar to Requires=, but limited to stopping and restarting of units. When systemd stops or restarts the units listed here, the action is propagated to this unit. Note that this is a one-way dependency — changes to this unit do not affect the listed units.
关于linux - 如果重新启动其依赖服务,如何重新启动服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36043964/