Upstart:在运行级停止vs在启动rc时停止RUNLEVEL =

所以,我正在为mysql创build一个新贵的init脚本。 应该是微不足道的吧? 我的停止节看起来像:

kill timeout 30 stop on runlevel [016] 

shutdown now -r ,并且mysql大叫我的MyISAM表崩溃,就像我会kill -9我的MySQL进程。 嘘。 Upstart似乎没有在重启之前等待mysql退出。 在Google上search一下,发现我这个链接暗示我做,而是:

 stop on starting rc RUNLEVEL=[016] 

事实上,这似乎解决了这个问题。

但是:WFT? 本质上,我想确保在试图卸载本地文件系统之前停止mysql。 这是正确的方法吗? 为什么我的stop on runlevelstop on runlevel不等待mysql切换运行级别之前停止?

而且:这是你知道吗,logging在任何地方?

这个问题实际上是Upstart在Ubuntu上处理Upstart作业和SystemV服务的灵活性。

有关事件的信息,您可以查看系统上的手册页。 如果你正在运行Ubuntu Natty或更新的版本,你现在将会有暴发事件(7):

 man 7 upstart-events 

这给了你很多的信息。 以下是(大部分)手册页的在线版本:

http://upstart.ubuntu.com/cookbook/#ubuntu-well-known-events-ubuntu-specific

目前,Ubuntu系统的closures实际上是由SysV方面(由于历史原因)最终确定的。 如果你stop on runlevel [016] ,那么当这个runlevel事件发出时,你的工作就会停止。 但是,如果时间过长,则系统的SystemV部分( /etc/init.d/* )将实际控制并closures系统。 然而,如果您stop on starting rc RUNLEVEL=[016]Upstart (不是SystemV)将运行您的工作, 一旦mysql停止 ,然后继续启动SystemVclosures序列。

Upstart Cookbook包含了很多这样的例子: