[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
howtos:slackware_admin:runit [2018/12/20 15:09 (UTC)] – chrisabela | howtos:slackware_admin:runit [2019/05/30 12:34 (UTC)] – chrisabela | ||
---|---|---|---|
Line 10: | Line 10: | ||
To read on the benefits of runit, see here: http:// | To read on the benefits of runit, see here: http:// | ||
+ | |||
+ | Unless otherwise stated, all commands in this article are to be run by root. | ||
===== 2. Use runit with traditional init ===== | ===== 2. Use runit with traditional init ===== | ||
Line 44: | Line 46: | ||
#!/bin/sh | #!/bin/sh | ||
RUNIT=x$( /sbin/pidof runsvdir ) | RUNIT=x$( /sbin/pidof runsvdir ) | ||
- | if [ “$RUNIT” != x ]; then | + | if [ "$RUNIT" |
kill $RUNIT | kill $RUNIT | ||
fi | fi | ||
Line 81: | Line 83: | ||
If you followed the previous chapter, then stop runsvdir and reverse all the changes that you made on your system. | If you followed the previous chapter, then stop runsvdir and reverse all the changes that you made on your system. | ||
- | Remove | + | So, remove |
< | < | ||
Line 87: | Line 89: | ||
</ | </ | ||
- | Reboot: | + | And reboot: |
< | < | ||
Line 95: | Line 97: | ||
Also, it is best to re-build and re-install runit | Also, it is best to re-build and re-install runit | ||
- | This time, when running slackbuild, do pass any value for CONFIG, or set it to yes: | + | This time, when running slackbuild, do pass not any value for CONFIG, or set it to yes: |
< | < | ||
Line 188: | Line 190: | ||
The traditional init reads ''/ | The traditional init reads ''/ | ||
- | The script ''/ | + | The script ''/ |
Note that the shutdown command provided by sysvinit package will not work in runit. To reboot you enter | Note that the shutdown command provided by sysvinit package will not work in runit. To reboot you enter | ||
Line 205: | Line 207: | ||
The '' | The '' | ||
+ | |||
+ | Desktop Environments call ''/ | ||
+ | |||
+ | < | ||
+ | mv / | ||
+ | ln -s / | ||
+ | </ | ||
+ | |||
+ | However consider that shutdown would not work for the original init. | ||
===== 6. runsv ===== | ===== 6. runsv ===== | ||
- | Although runit may replace init as the PID 1 daemon, there is not much benefit unless other services are migrated from Slackware’s BSD style to runsv(8). While this is not a complicated task, some familiarisation with runit’s characteristics is recommended and makes the task easier. This short example should help illustrate runsv to new users. | + | Although runit may replace init as the PID 1 daemon, there is not much benefit unless other services are migrated from Slackware's BSD style to runsv(8). While this is not a complicated task, some familiarisation with runit's characteristics is recommended and makes the task easier. This short example should help illustrate runsv to new users. |
Make an arbitrary directory under ''/ | Make an arbitrary directory under ''/ | ||
Line 216: | Line 227: | ||
</ | </ | ||
- | In order to let the non-privileged | + | As a non-priviliged |
- | + | ||
- | < | + | |
- | chmod -R chris.users / | + | |
- | </ | + | |
- | + | ||
- | As a non-priviliged user, create some directories | + | |
< | < | ||
- | mkdir -p /home/chris/runit/logs | + | mkdir -p /home/bob/runit/logs |
</ | </ | ||
- | Then edit a script that simulates a (finicky) service in a convenient directory; say | + | Then edit a ''/ |
< | < | ||
Line 245: | Line 250: | ||
< | < | ||
- | chmod +x /home/chris/ | + | chmod +x /home/bob/ |
</ | </ | ||
Line 251: | Line 256: | ||
< | < | ||
- | /home/chris/ | + | /home/bob/ |
</ | </ | ||
- | Edit a file called ''/ | + | Log in back as root and edit a file called ''/ |
< | < | ||
#!/bin/sh -e | #!/bin/sh -e | ||
exec 2>&1 | exec 2>&1 | ||
- | exec chpst -u chris /home/chris/ | + | exec chpst -u bob /home/bob/ |
</ | </ | ||
Line 276: | Line 281: | ||
</ | </ | ||
- | and edit another file under it also called ''/ | + | and edit another file under it, also called ''/ |
< | < | ||
#!/bin/sh | #!/bin/sh | ||
- | exec chpst -u chris svlogd -tt /home/chris/runit/logs | + | exec chpst -u bob svlogd -tt /home/bob/runit/logs |
</ | </ | ||
Line 289: | Line 294: | ||
</ | </ | ||
- | Run the sv service to ensure that it works: | + | Run the service to ensure that it works: |
< | < | ||
Line 301: | Line 306: | ||
</ | </ | ||
- | Watch how your “service” works, crashes, but it is recovered by runit: | + | Watch how your "service" |
+ | |||
+ | As your non-privilged user: | ||
< | < | ||
- | tail -f /home/chris/ | + | tail -f /home/bob/runit/ |
</ | </ | ||
+ | |||
+ | Hit CTRL+C to exit. | ||
+ | |||
+ | Finally, login back as root and let bob take the ownership of the whole ''/ | ||
+ | |||
+ | < | ||
+ | chown -R bob.users / | ||
+ | </ | ||
+ | |||
+ | Now bob can manage this service with the '' | ||
===== 7. Managing Services with sv ===== | ===== 7. Managing Services with sv ===== | ||
Line 326: | Line 343: | ||
sv s /service/* | sv s /service/* | ||
</ | </ | ||
+ | |||
==== 7.1. Stop/ | ==== 7.1. Stop/ | ||
Line 346: | Line 364: | ||
</ | </ | ||
- | Each of these is a shortcut, for ‘up’, ‘down’, and ‘terminate’, respectively. Only the first letter of each word is recognised. | + | Each of these is a shortcut, for 'up', 'down', and 'terminate', respectively. Only the first letter of each word is recognised. |
- | More verbose forms of the above | + | |
+ | More verbose forms of the above: | ||
< | < | ||
- | sv start sshd | + | sv start example |
- | sv stop sshd | + | sv stop example |
- | sv restart | + | sv restart |
</ | </ | ||
Line 390: | Line 409: | ||
touch / | touch / | ||
</ | </ | ||
+ | |||
==== 7.4. Dependencies ==== | ==== 7.4. Dependencies ==== | ||
Line 399: | Line 419: | ||
. | . | ||
. | . | ||
- | exec … | + | exec ... |
</ | </ | ||
+ | |||
===== 8. Runlevels ===== | ===== 8. Runlevels ===== | ||
Line 424: | Line 445: | ||
You can edit the runsvdir line of ''/ | You can edit the runsvdir line of ''/ | ||
+ | |||
===== 9. run scripts ===== | ===== 9. run scripts ===== | ||
Only one executable can be called for a service and the last line must be called by the '' | Only one executable can be called for a service and the last line must be called by the '' | ||
- | In direct contrast to Slackware’s BSD style service scripts, runit run scripts must not must run in the foreground, otherwise runit would think that they have crashed and restart them. | + | In direct contrast to Slackware's BSD style service scripts, runit run scripts must not must run in the foreground, otherwise runit would think that they have crashed and restart them. |
For some services, this may not be possible, but there are workarounds. You can forcefully terminate them by ending the run script like this: | For some services, this may not be possible, but there are workarounds. You can forcefully terminate them by ending the run script like this: | ||
Line 444: | Line 466: | ||
===== 10. Migrating Services ===== | ===== 10. Migrating Services ===== | ||
- | It is suggested that services are migrated from stage 2 (which are still under the Slackware’s BSD init scheme) to stage 3 carefully. Start from the bottom of ''/ | + | It is suggested that services are migrated from stage 2 (which are still under the Slackware's BSD init scheme) to stage 3 carefully. Start from the bottom of ''/ |
Then continue for ''/ | Then continue for ''/ | ||
- | Proceed with other services to benefit’s from runit features. Note that for some services, such as '' | + | Proceed with other services to benefit's from runit features. Note that for some services, such as '' |
- | Let’s take the popular '' | + | Let's take the popular '' |
Stop the service: | Stop the service: | ||
Line 489: | Line 511: | ||
</ | </ | ||
- | For '' | + | If run exits and '' |
+ | |||
+ | It is stuggested to let '' | ||
===== 11. Sources ===== | ===== 11. Sources ===== | ||
Line 513: | Line 537: | ||
<!-- Please do not modify anything below, except adding new tags.--> | <!-- Please do not modify anything below, except adding new tags.--> | ||
{{tag> | {{tag> | ||
- |