新贵作业和依赖关系

时间:2018-04-08 12:11:25

标签: upstart

我们有三个职位,job1,job2和job3。 job3取决于其他两个:

job3 config

start on (started job1 and started job2)
stop on (stopping job1 or stopping job2)

使用此配置,job3在OS启动时启动。如果其他两个中的一个失败,比如job1,job3将停止;但是如果job1从失败中恢复,那么job3将不会启动,因为upstart has events, not states

一种可能的解决方法是检查job1的启动后脚本中job2的状态,如果它正在运行,则发出一个事件来触发job3的启动,具有相同的job2逻辑:

job1 config

post-start script
  if job2 is running emit event
end

job2 config

post-start script
  if job1 is running emit event
end

job3 config

start on event

这显然不是一个干净的解决方案,需要在创建更多工作时更改。 有没有更好的方法呢?

0 个答案:

没有答案
相关问题