RHEL init.d 脚本中的 chkconfig 行应该为像 supervisord 这样的进程控制器设置什么?

What should the chkconfig line in a RHEL init.d script be set to for a process controller like supervisord?

我第一次尝试编写 init.d 脚本来启动 supervisord 进程。 Supervisor 是一个进程 controller/manager,如 runitupstartsystemd。我希望它在系统重新启动时自动启动,以便它可以启动我的应用程序。

我以此tldp tutorial为基础编写了init.d脚本。它工作正常,但我不明白我应该如何修改文件中的这一行:

# chkconfig: 2345 95 05

该行教程中的注释指出:

Although these are comments, they are used by chkconfig command and must be present. This particular line defines that on runlevels 2,3,4 and 5, this subsystem will be activated with priority 95 (one of the lasts), and deactivated with priority 05 (one of the firsts).

RHEL doc 解释了各种 运行 级别:

0 - Halt
1 - Single-user text mode
2 - Not used (user-definable_
3 - Full multi-user text mode
4 - Not used (user-definable)
5 - Full multi-user grapical mode
6 - Reboot

根据这些选择,我想我想 运行 在 35 上进行挖掘,假设 1 仅供系统管理员使用。

有一些示例 supervisord init.d 脚本,例如 here。我注意到所有 RHEL init.d 脚本都包含以下行:

# chkconfig:    345 83 04

在这种情况下,作者有什么理由希望它在 运行 级别 4 上处于活动状态,即 "not used"?

我安装的 nginx init.d 脚本包含这一行:

# chkconfig:   - 86 16

- 对这里的 运行 级别意味着什么?

为什么这行不包含停用优先级?

如何决定像 supervisor 这样的过程控制器的优先级?上面的脚本选择了 83 和 04,而 tldp 教程选择了 95 和 05。

chkconfig:    345 83 04

In this case, what reason could the authors have to want it to be active on runlevel 4, which is "not used" ?

由于未使用运行级别 4,因此无论您将其设置为打开还是关闭都无所谓。 345比较好写,偷懒的办法。

您以后随时可以通过

更改它
chkconfig --list supervisord
chkconfig --level 4 supervisord off
chkconfig --level 3 supervisord on

The nginx init.d script that I installed contains this line:

chkconfig:   - 86 16

What does the - mean for the runlevel here?

这意味着你必须用级别替换破折号或保持原样由 chkconfig

设置
chkconfig:   345 86 16

Why does this line not contain a deactivate priority?

345 run levels
86  activate priority
16  deactivate priority

How does one decide upon the priority levels for a process controller like supervisor? The scripts above chose 83 and 04, whereas the tldp tutorial chose 95 and 05.

这些是示例,不是真实的,它们的设置不同。

优先级一般无所谓,因为你的机器不定时开机或关机,我对你的应用不熟悉,我会推荐这个。

此 url 包含不同的优先级 https://rayed.com/wordpress/?p=1496

    chkconfig: 345 64 36

或保持原样,让 chkconfig 为您配置

chkconfig: - 64 36

我在我的系统centOS上查看了我的答案,新推荐:

使用 yum 安装 supervisord,保持默认优先级,因为它正在被许多其他人测试

urname -r
2.6.32-573.12.1.el6.centos.plus.x86_64

安装主管:

sudo yum install supervisor
supervisor.noarch 0:2.1-9.el6

此版本 supervisord 的默认优先级是:

cat /etc/init.d/supervisord |grep chkconfig
#chkconfig: - 95 04

改变on/off而不改变supervisord

[gliang@www prima]$ chkconfig --list supervisord
supervisord     0:off   1:off   2:off   3:off   4:off   5:off   6:off
[gliang@www prima]$ sudo chkconfig --level 3 supervisord on
[gliang@www prima]$ sudo chkconfig --level 4 supervisord off

级别 3 上的 S95 几乎具有最低优先级,晚启动,先关闭

[gliang@www prima]$ ls -ltr /etc/rc3.d/|grep supervisor
lrwxrwxrwx. 1 root root 21 Jan 29 08:02 S95supervisord -> ../init.d/supervisord
[gliang@www prima]$ ls -ltr /etc/rc4.d/|grep supervisor
lrwxrwxrwx. 1 root root 21 Jan 29 08:02 K04supervisord -> ../init.d/supervisord

使用它来列出和查看该级别上所有守护进程的优先级

ls -ltr /etc/rc3.d/

这来自 Red Hat sysvinitfiles 文档,在我的例子中是 CentOS 6.10。

# chkconfig:

必填。 是默认启动服务的级别列表。 是优先级数字。例如:

#检查配置:2345 20 80

阅读 'man chkconfig' 了解更多信息。

除非有非常好的、明确的相反理由,否则 应等于 100 -