我已经创build了两个服务,一个用于rails应用程序,另一个用于其delayed_job进程,我想重新启动delayed_job服务,每次rails服务重新启动,我可以用systemd来做这个吗?
你应该考虑使用BindsTo over 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.
Requires=在delayed_job systemd文件中执行作业:
[Unit] Requires=rails.service
( man systemd.unit )