为什么要在Required-start中设置相同的值,就像在init中所做的那样。d脚本?

时间:2022-06-22 15:38:53

The Debian wiki gives the following example for 'INIT INFO`:

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

Then the documentation says the following about Required-stop:

然后文档说明了以下的要求:

Required-Stop: boot_facility_1 [boot_facility_2...]

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.

定义由脚本提供的服务使用的设施。该脚本提供的设施应该在被列出的设施停止前停止,以避免冲突。通常,您将在这里包含与Required-Start关键字相同的设备。

Isn't it pointless to set the same values to Required-Start if it's not going to run until the facility is stopped?

如果在停止运行之前,设置相同的值以请求启动,这不是毫无意义的吗?

2 个解决方案

#1


4  

Required-Stop: boot_facility_1 [boot_facility_2...]

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.

定义由脚本提供的服务使用的设施。该脚本提供的设施应该在被列出的设施停止前停止,以避免冲突。通常,您将在这里包含与Required-Start关键字相同的设备。

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.

这是为了防止,例如,$remote_fs被停止,您的NFS装载/usr和/var在您的数据库服务器有机会安全关闭并正确地将数据库保存到文件系统之前卸载。

#2


0  

An additional example: I run VirtualBox inside a VNC server, started by two different init scripts.

另外一个例子:我在VNC服务器中运行VirtualBox,由两个不同的init脚本启动。

I want the VirtualBox to close before VNC. Because if VNC closes first, VirtualBox may be killed instead of shutting down cleanly!

我想要在VNC之前关闭VirtualBox。因为如果VNC先关闭,那么VirtualBox可能会被杀死而不是彻底关闭!

So I specify that my VirtualBox init scripts depends on VNC for starting up, and also for closing down.

因此,我指定了我的VirtualBox初始化脚本依赖于VNC启动,以及关闭。

#1


4  

Required-Stop: boot_facility_1 [boot_facility_2...]

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.

定义由脚本提供的服务使用的设施。该脚本提供的设施应该在被列出的设施停止前停止,以避免冲突。通常,您将在这里包含与Required-Start关键字相同的设备。

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.

这是为了防止,例如,$remote_fs被停止,您的NFS装载/usr和/var在您的数据库服务器有机会安全关闭并正确地将数据库保存到文件系统之前卸载。

#2


0  

An additional example: I run VirtualBox inside a VNC server, started by two different init scripts.

另外一个例子:我在VNC服务器中运行VirtualBox,由两个不同的init脚本启动。

I want the VirtualBox to close before VNC. Because if VNC closes first, VirtualBox may be killed instead of shutting down cleanly!

我想要在VNC之前关闭VirtualBox。因为如果VNC先关闭,那么VirtualBox可能会被杀死而不是彻底关闭!

So I specify that my VirtualBox init scripts depends on VNC for starting up, and also for closing down.

因此,我指定了我的VirtualBox初始化脚本依赖于VNC启动,以及关闭。