我已经创建了两个服务,一个用于 rails 应用程序,另一个用于其 delayed_job 进程,我想每次重新启动 rails 服务时都重新启动 delayed_job 服务,我可以使用 systemd 来做到这一点吗?
答案1
您应该考虑使用BindsTo
超过Requires
man systemd.unit
BindsTo=
Configures requirement dependencies, very similar in style to Requires=, however in addition to this behavior, it also
declares that this unit is stopped when any of the units listed suddenly disappears. Units can suddenly, unexpectedly
disappear if a service terminates on its own choice, a device is unplugged or a mount point unmounted without
involvement of systemd.
答案2
Requires=
在 delayed_job systemd 文件上执行以下作业:
[Unit]
Requires=rails.service
(man systemd.unit
)