为什么要在必需启动中设置与 init.d 脚本中必需停止相同的值?
Debian wiki 给出了“INIT INFO”的以下示例:
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
然后文档说明了以下关于必需停止的内容:
必需停止:boot_facility_1 [boot_facility_2...]
定义服务使用的设施 由脚本提供。设施 该脚本提供的应该停止 在列出的设施之前 停下来避免冲突。 通常情况下 你会在这里包括相同的 所需启动设施 关键字。
如果 Required-Start
在设施停止之前不会运行,那么为 Required-Start
设置相同的值不是毫无意义吗?
The Debian wiki gives the following example for 'INIT INFO`:
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
Then the documentation says the following about Required-stop:
Required-Stop: boot_facility_1 [boot_facility_2...]
defines facilities used by the service
provided by the script. The facility
provided by this script should stop
before the listed facilities are
stopped to avoid conflicts. Normally
you would include here the same
facilities as for the Required-Start
keyword.
Isn't it pointless to set the same values to Required-Start
if it's not going to run until the facility is stopped?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Required-Stop 用于指示在当前脚本提供的设施停止之前不应停止列出的设施。
例如,这是为了防止在数据库服务器有机会安全关闭并将数据库正确保存到文件系统之前,$remote_fs 被停止以及 NFS 挂载的 /usr 和 /var 被卸载。
Required-Stop is used to indicate that listed facilities should not be stopped before the ones provided by the current script are stopped.
This is to prevent, for example, $remote_fs from being stopped and your NFS mounted /usr and /var being unmounted before your database server has a chance to shutdown safely and properly save the database to the filesystem.
另一个例子:我在 VNC 服务器内运行 VirtualBox,由两个不同的初始化脚本启动。
我希望 VirtualBox 在 VNC 之前关闭。因为如果VNC先关闭,VirtualBox可能会被杀死而不是干净地关闭!
因此,我指定 VirtualBox 初始化脚本依赖于 VNC 来启动和关闭。
An additional example: I run VirtualBox inside a VNC server, started by two different init scripts.
I want the VirtualBox to close before VNC. Because if VNC closes first, VirtualBox may be killed instead of shutting down cleanly!
So I specify that my VirtualBox init scripts depends on VNC for starting up, and also for closing down.