系统相关
首页 > 系统相关> > nginx – RHEL init.d脚本中的chkconfig行应该设置为像supervisord这样的流程控制器?

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

作者:互联网

我正在尝试第一次编写init.d脚本来启动supervisord进程. Supervisor是一个过程控制器/管理器,如runit,upstart或systemd.如果系统重新启动,我希望它自动启动,以便它可以启动我的应用程序.

我用这个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上激活,这是“未使用”?

我安装的nginx init.d脚本包含以下行:

# chkconfig:   - 86 16

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

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

如何确定过程控制器(如主管)的优先级?上面的脚本选择了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.

这些都是例子,而不是真实的东西,它们的设置不同.

优先级通常无关紧要,因为您不会定期启动或关闭机器,我不熟悉您的应用程序,我会推荐这个.

此网址包含不同的优先级
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

安装supervisord:

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

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

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

在不改变监督的情况下改变开/关

[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/

标签:nginx,init,supervisord,init-d,rhel
来源: https://codeday.me/bug/20190702/1356063.html