带有 LSB 标头的启动脚本无法正常工作(依赖性问题?)

带有 LSB 标头的启动脚本无法正常工作(依赖性问题?)

我正在为我的 Ubuntu 14.04.1 LTS 服务器创建启动脚本。该脚本需要在 Rabbit MQ 服务器之后运行。Rabbit MQ 启动脚本说它提供了“rabbitmq-server”。因此,我将这个字符串放在启动脚本标头的“Required-Start”列表中(见下文)。但是,在使用 update-rc 安装我的脚本后,Rabbit MQ 脚本和我的脚本都处于“S20”级别,也就是说,我认为依赖关系没有起作用。我的脚本也无法正确启动,但如果我在启动后手动运行它,它确实可以启动。有什么想法可以解决什么问题吗?

### BEGIN INIT INFO
# Provides: amqp_receive
# Required-Start: $local_fs $network rabbitmq-server
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Script to provide start/stop/status of the amqp_receive program
### END INIT INFO
lrwxrwxrwx 1 root root  22 Aug 17 00:29 S20amqp-receive -> ../init.d/amqp-receive
lrwxrwxrwx 1 root root  25 Aug 13 18:14 S20rabbitmq-server -> ../init.d/rabbitmq-server
lrwxrwxrwx 1 root root  15 Apr 16 18:26 S20rsync -> ../init.d/rsync
lrwxrwxrwx 1 root root  24 Apr 16 18:26 S20screen-cleanup -> ../init.d/screen-cleanup
lrwxrwxrwx 1 root root  23 Apr 16 18:26 S38open-vm-tools -> ../init.d/open-vm-tools
lrwxrwxrwx 1 root root  26 Apr 16 18:26 S45landscape-client -> ../init.d/landscape-client
lrwxrwxrwx 1 root root  19 Apr 16 18:26 S70dns-clean -> ../init.d/dns-clean
lrwxrwxrwx 1 root root  18 Apr 16 18:26 S70pppd-dns -> ../init.d/pppd-dns
lrwxrwxrwx 1 root root  21 Apr 16 18:26 S99grub-common -> ../init.d/grub-common
lrwxrwxrwx 1 root root  18 Apr 16 18:25 S99ondemand -> ../init.d/ondemand
lrwxrwxrwx 1 root root  18 Apr 16 18:25 S99rc.local -> ../init.d/rc.local

答案1

问题是脚本按字母顺序运行(正如您上面所说,问题是它们都以 开头S20) - 所以S20amqp-receive在 之前运行S20rabbitmq-server。我同意你的看法,执行时出了点问题update-rc.d。也许只是update-rc.d amqp-receive defaults再次执行。

另一种解决方案可能是仅(手动)重命名S20amqp-receiveS21amqp-receive.那么这个脚本将会在 . 开头的脚本之后执行S20

笔记:尝试修复依赖关系会更好。

相关内容