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

2

6

I'm trying to write a init.d script for the first time to start a supervisord process. Supervisor is a process controller/manager like runit, upstart, or systemd. I would like it to start automatically if the system reboots, so that it can start my applications.

I used this tldp tutorial as a base to write an init.d script. It works fine but I don't understand how I should modify this line in the file:

# chkconfig: 2345 95 05

The note in the tutorial for this line states:

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).

This RHEL doc explains the various runlevels as so:

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

From these choices, I suppose I would like to run mine on 35, assuming that 1 is only for system administrators.

There are a few example supervisord init.d scripts, for example here. I noticed that all of the RHEL init.d scripts contain the following line:

# 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" ?

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

# chkconfig:   - 86 16

What does the - mean for the runlevel here?

Why does this line not contain a 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.

Vicenta answered 20/1, 2016 at 0:15 Comment(5)
I wonder why people do not answer this question? it is fairly straight forward, you used up all 5 tags. and I cannot add anymoreRobbery
@Robbery perhaps my bounty was too small :(Vicenta
most posts with your tags ended up no upvote, no answer in the past, guess you shoud try Linux Unix stackexchange, Good luck!Robbery
@Gang, odd, I received 3 extra votes after I marked your answer as correct.Vicenta
Your question is great and it remind of me the RHCE exam questions and should attract more upvote if it is a python or perl question. thank youRobbery
R
4
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" ?

Since runlevel 4 is not used, so it does not matter you set it on or off. 345 is easier to write, lazy approach.

and you can always change it later by

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?

it means you have to replace the dash with the levels or keep as is to be set by 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.

Those are examples, not really the real thing, they are set differently.

The priority normally does not matter, because you do not power up or power down your machines regularly, I am not familiar with your apps, I would recommend this one.

This url contains a different priority https://rayed.com/wordpress/?p=1496

    chkconfig: 345 64 36

or keep as is, to let the chkconfig to configure it for you

chkconfig: - 64 36

I checked my answer on my system centOS, new recommendation:

use yum to install supervisord, keep the default priority as it is being tested by many others

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

Install supervisord:

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

The default priority for this version of supervisord is:

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

Change on/off without changing the 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

The S95 on level 3 has almost lowest priority, start late, shutdown first

[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

use this to list and to see the priority of all daemons on this level

ls -ltr /etc/rc3.d/
Robbery answered 29/1, 2016 at 3:7 Comment(1)
I realized this morning that different build and version might have different default setting, although it does not really matter, it is safe and easy just to follow the default. thanksRobbery
F
0

This is from the Red Hat sysvinitfiles document, in my case CentOS 6.10.

# chkconfig: <startlevellist> <startpriority> <endpriority>

Required. <startlevellist> is a list of levels in which the service should be started by default. <startpriority> and <endpriority> are priority numbers. For example:

# chkconfig: 2345 20 80

Read 'man chkconfig' for more information.

Unless there is a VERY GOOD, EXPLICIT reason to the contrary, the <endpriority> should be equal to 100 - <startpriority>

Frodin answered 6/4, 2020 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.