Upstart task怎么用呢?

这句话怎么理解呢?

测试结果困惑,加上task执行顺序似乎没有变?

红框是加上task运行结果,蓝框是不加task运行结果。

阅读 1.6k
2 个回答

要结合上一段一起看。

REF: https://upstart.ubuntu.com/co...

In concept, a task is just a short lived job. In practice, this is accomplished by changing how the transition from a goal of "stop" to "start" is handled.

Without the 'task' keyword, the events that cause the job to start will be unblocked as soon as the job is started. This means the job has emitted a starting(7) event, run its pre-start, begun its script/exec, and post-start, and emitted its started(7) event.

With task, the events that lead to this job starting will be blocked until the job has completely transitioned back to stopped. This means that the job has run up to the previously mentioned started(7) event, and has also completed its post-stop, and emitted its stopped(7) event.

说白了就是 start on started <JOB> 这里的 started 到底时什么时候触发的。

  • 没有 task 时:

pre-start → starting → post-start → started → running → pre-stop → stopping → post-stop → stopped

是在 post-start 之后。

  • task 时:

pre-start → starting → post-start → running → pre-stop → stopping → post-stop → started → stopped

是在 post-stop 之后。

现在新的各个发行版都是systemd了。不用再看upstart了吧。

upstart参考资料:https://www.cnblogs.com/plxx/...
摘抄:

Upstart 为每个工作都维护一个生命周期。一般来说,工作有开始,运行和结束这几种状态。为了更精细地描述工作的变化,Upstart 还引入了一些其它的状态。比如开始就有开始之前(pre-start),即将开始(starting)和已经开始了(started)几种不同的状态,这样可以更加精确地描述工作的当前状态。

关于systemd的参考资料:http://ruanyifeng.com/blog/20...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进