简体   繁体   English

暴发户任务阻止工作开始

[英]upstart task preventing job from starting

I have task A and job B. Here are couple oversimplified examples. 我有任务A和工作B。这是几个过于简化的示例。

task-a.conf task-a.conf

start on startup and starting job-b
console log
task
script
    logger "hello"
end script

job-b.conf job-b.conf

start on (runlevel [2345]
          and stopped networking)
stop on starting rc RUNLEVEL=[016]
console log
script
        logger "world"
end script

Task A needs to run once, before job B starts. 在作业B开始之前,任务A需要运行一次。 When the system starts up, all is well and task A fires, and job B starts. 系统启动时,一切正常,任务A触发,作业B开始。 But when manually stopping job B and starting it again, it waits forever. 但是,当手动停止作业B并再次启动它时,它将永远等待。 I'm missing something here, but how do I get task A to fire once before job B, but not have job B be blocked forever by task A on additional stop/start actions? 我在这里丢失了一些东西,但是如何使任务A在作业B之前触发一次,但又不会让作业B在其他停止/启动操作中永远被作业B阻止呢? I can not change job B to check for task A to have stopped. 我无法更改作业B来检查任务A是否已停止。 In certain implementations, task A may or may not be there. 在某些实施方式中,任务A可以存在或不存在。

This is on Ubuntu 12.04 with latest updates. 这是在Ubuntu 12.04上的最新更新。 Thanks. 谢谢。

The starting stanza was blocking my job from completely starting. 起始节阻止了我的工作完全开始。 In the example given above, job-b is blocked until task-a has completed. 在上面给出的示例中,作业b被阻塞,直到任务a完成。 Unfortunately task-a is waiting for the startup event, which has long passed. 不幸的是,任务-a正在等待启动事件,该事件已经过去了很长时间。

The solution was to remove the wait for the startup event. 解决方案是删除等待启动事件。 Next I wanted task-a to run, but only once per boot. 接下来,我希望任务-a运行,但每次启动仅运行一次。 For this I added a pre-start script which checked to see if /run/.task-a existed. 为此,我添加了一个启动前脚本,用于检查/run/.task-a是否存在。 If it did not, then task would run and create /run/.task-a. 如果没有,则任务将运行并创建/run/.task-a。 Any time job-b would be started again, it would check for /run/.task-a and then exit since it existed. 每当job-b重新启动时,它都会检查/run/.task-a,然后退出,因为它存在。 You can also create a job that runs indefinitely, see /etc/init/network-interface-security.conf. 您还可以创建无限期运行的作业,请参见/etc/init/network-interface-security.conf。

start on startup and starting job-b
console log
task
pre-start script
    if [ -e /var/.$UPSTART_JOB ]; then
        stop; exit 0
    fi
end script

script
     logger "hello"
end script

post-start exec touch /var/.$UPSTART_JOB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM