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

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
playground:runit [2018/12/19 20:08 (UTC)] – [7.3 Dependencies] chrisabelaplayground:runit [2018/12/19 20:26 (UTC)] – [10. Migrating Services] chrisabela
Line 403: Line 403:
 ===== 8. Runlevels ===== ===== 8. Runlevels =====
  
-If you installed the slackbuild configuration files, you have two runlevels: default and single. The current runlevel is default. You can verify by looking under /etc/runit/runsvdir/, you will see that /etc/runit/current is a symbolic link /etc/runit/default.+If you installed the slackbuild configuration files, you have two runlevels: default and single. The current runlevel is default. You can verify by looking under ''/etc/runit/runsvdir/,'' you will see that ''/etc/runit/current'' is a symbolic link ''/etc/runit/default''.
  
 Change runlevel to another runlevel; single: Change runlevel to another runlevel; single:
  
 +<code>
 runsvchdir single runsvchdir single
 +</code>
  
-You will see that /etc/runit/runsvdir/current is now symbolically linked to /etc/runit/runsvdir/single +You will see that ''/etc/runit/runsvdir/current'' is now symlinked to ''/etc/runit/runsvdir/single'' and ''/etc/runit/runsvdir/previous'' is symlinked to ''/etc/runsvdir/default''. If you reboot, you will boot again default runlevel as you have this entry in ''/etc/runit/2''
-and /etc/runit/runsvdir/previous is symbolically linked to /etc/runsvdir/default. If you reboot, you will boot again default runlevel as you have this entry in /etc/runit/2+
  
 +<code>
 runsvchdir default >/dev/null runsvchdir default >/dev/null
 +</code>
  
-You can create any other runlevels and name them as you like. To start you can copy an existing runlevel directory and modify as you wish. +You can create any other runlevel and name them as you like. To start you can copy an existing runlevel directory and modify as you wish. 
  
 +<code>
 cp -ar /etc/runit/runsvdir/default /etc/runit/runsvdir/custom/ cp -ar /etc/runit/runsvdir/default /etc/runit/runsvdir/custom/
 +</code>
  
-Likewise, you edit the runsvdir line of /etc/runit/2 +You can edit the runsvdir line of ''/etc/runit/2'' to your requirements.
 ===== 9. run scripts ===== ===== 9. run scripts =====
  
-Only one executable can be called for a service and the last line must be called by the exec command. There are some generic runit run scripts on the Internet, in other Linux distributions or other Slackers who post them on publicly available repositories. The author of this article has placed his here: https://gitlab.com/chrisabela/runit_scripts_for_slackware+Only one executable can be called for a service and the last line must be called by the ''exec'' command. There are some generic runit run scripts on the Internet, in other Linux distributions. Also, other Slackers may post them on publicly available repositories. The author of this article has placed his here: https://gitlab.com/chrisabela/runit_scripts_for_slackware
  
-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 that 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:
  
 +<code>
 sv d service_name sv d service_name
 +</code>
  
-Or you can use the pause command to keep the service alive. pause is a trivial command that will simply not exit, until it is killed (akin tail -f /dev/null). A slackbuild for pause is available in https://slackbuilds.org Then end the run script with:+Or you can use the ''pause'' command to keep the service alive. ''pause'' is a trivial command that will simply not exit, until it is killed (akin to tail -f /dev/null). A SlackBuild for ''pause'' is available at https://slackbuilds.org Then end the run script with:
  
 +<code>
 exec chpst -b service_name pause exec chpst -b service_name pause
 +</code>
  
 ===== 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 end of /etc/rc.d/rc.M and work up. This means that you should start with any entries under /etc/rc.d/rc.local +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 ''/etc/rc.d/rc.M'' and work up. This means that you should start with any entries under ''/etc/rc.d/rc.local'' 
  
-Then continue for /etc/rc.d/rc.S+Then continue for ''/etc/rc.d/rc.S''
  
-Proceed with other services to benefit’s from runit features. Note that for some services, such as atd and crond, you would need to edit /etc/rc.d/rc.M as they are hard-coded.+Proceed with other services to benefit’s from runit features. Note that for some services, such as ''atd'' and ''crond'', you would need to edit ''/etc/rc.d/rc.M'' as they are hard-coded.
  
-Let’s take the popular NetworkManager service as an example. According to the permission of /etc/rc.d/rc.networkmanager this script is called by /etc/rc.d/rc.M The latter is called by /etc/runit/2 (stage 2).+Let’s take the popular ''NetworkManager'' service as an example. According to the permission of ''/etc/rc.d/rc.networkmanager'' this script is called by ''/etc/rc.d/rc.M'' The latter is called by ''/etc/runit/2'' (stage 2).
  
 Stop the service: Stop the service:
  
 +<code>
 /etc/rc.d/rc.networkmanager stop /etc/rc.d/rc.networkmanager stop
 +</code>
  
 Disable it: Disable it:
  
 +<code>
 chmod -x /etc/rc.d/rc.networkmanager chmod -x /etc/rc.d/rc.networkmanager
 +</code>
  
 Create a suitable directory for runit Create a suitable directory for runit
  
 +<code>
 mkdir /etc/sv/networkmanager/ mkdir /etc/sv/networkmanager/
 +</code>
  
-Write a runit run script: /etc/sv/networkmanager/run+Write a runit run script: ''/etc/sv/networkmanager/run''
  
 +<code>
 #!/bin/sh #!/bin/sh
 prefix=/usr prefix=/usr
Line 466: Line 481:
 export XDG_CACHE_HOME=/root/.cache  export XDG_CACHE_HOME=/root/.cache 
 exec $NETWORKMANAGER_BIN -n > /dev/null 2>&1 exec $NETWORKMANAGER_BIN -n > /dev/null 2>&1
 +</code>
  
-Symlink it to /service and NetworkManager to enable under current runlevel and it will start in a few seconds:+Symlink the ''/etc/sv/networkmanager'' directory to ''/service'' to enable under current runlevel and it will start in a few seconds:
  
 +<code>
 ln -s /etc/sv/networkmanager /service ln -s /etc/sv/networkmanager /service
 +</code>
  
-For udev, it is stuggested to let it under runit’s stage 2, but you can setup its monitoring for stage 3. +For ''udev'', it is stuggested to let it under runit’s stage 2, but you can setup its monitoring for stage 3. 
  
 +===== 11 Sources =====
 + 
 +(1) http://smarden.org/runit/
  
-Sources:  +(2) https://slackbuilds.org
-http://smarden.org/runit/+
  
-https://slackbuilds.org+(3) https://en.wikipedia.org/wiki/Init
  
-https://en.wikipedia.org/wiki/Init+(4) https://voidlinux.org/usage/runit/
  
-https://voidlinux.org/usage/runit/+(5) https://www.youtube.com/watch?v=jiBlIhFxNJo
  
-https://www.youtube.com/watch?v=jiBlIhFxNJo+(6) http://kchard.github.io/runit-quickstart/
  
-http://kchard.github.io/runit-quickstart/+(7) https://www.slackbook.org/beta/
  
-https://www.slackbook.org/beta/+(8) https://gitlab.com/chrisabela/runit_scripts_for_slackware
  
-https://gitlab.com/chrisabela/runit_scripts_for_slackware+  * Written for Slackware 14.2 in December 2018 
 +  * Originally written by [[wiki:user:chrisabela | Chris Abela]] 
 +<!-- Please do not modify anything below, except adding new tags.--> 
 +{{tag>init runit}}
  
-Author: Chris Abela for Slackware 14.2 
-December 2018 
 playground:runit ()