The officially official Devuan Forum!

You are not logged in.

#26 2021-03-01 14:41:13

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Runit

I have tried runit as a supervisor under SysVinit and under OpenRC and reported what I did to get various services supervised by runit at :-

https://dev1galaxy.org/viewtopic.php?id=1748

The part about Postfix rambles on a bit and eventually I got a much simpler set-up for it, which is included at the above link.

There are some further links including OpenRC at :-

https://dev1galaxy.org/viewtopic.php?pid=23816#p23816

Geoff

Offline

#27 2021-03-07 17:20:25

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Runit

I added a few more services to runit using the three-step procedure I posted above.
- copy the sample files to /etc/sv/
- stop the service with  /etc/init.d/<service> stop
- add the service with  update-service --add /etc/sv/<service>

Added dbus, elogind, lightdm and all seems to be working.

# sv status /etc/sv/*
run: /etc/sv/acpid: (pid 1894) 1238s; run: log: (pid 1891) 1238s
down: /etc/sv/anacron: 1238s, normally up; run: log: (pid 1895) 1238s
run: /etc/sv/cron: (pid 1874) 1238s; run: log: (pid 1872) 1238s
run: /etc/sv/dbus: (pid 1885) 1238s; run: log: (pid 1884) 1238s
run: /etc/sv/elogind: (pid 1886) 1238s; run: log: (pid 1883) 1238s
run: /etc/sv/getty-tty1: (pid 1873) 1238s
run: /etc/sv/getty-tty2: (pid 1852) 1238s
run: /etc/sv/getty-tty3: (pid 1855) 1238s
run: /etc/sv/getty-tty4: (pid 1853) 1238s
run: /etc/sv/getty-tty5: (pid 1876) 1238s
run: /etc/sv/getty-tty6: (pid 1869) 1238s
warning: /etc/sv/getty-ttyS0: unable to open supervise/ok: file does not exist
run: /etc/sv/lightdm: (pid 1878) 1238s; run: log: (pid 1877) 1238s
run: /etc/sv/mdadm: (pid 1901) 1238s; run: log: (pid 1900) 1238s
run: /etc/sv/network-manager: (pid 1871) 1238s; run: log: (pid 1870) 1238s
run: /etc/sv/ssh: (pid 1899) 1238s; run: log: (pid 1898) 1238s

Edit: fixed typo. Thanks.

Offline

#28 2021-03-08 10:00:21

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Runit

fsmithred wrote:

- add the service with  update-service --add <service>

Ah! Thank you for that. I thought that there should be a command to add in a new service rather than just putting in a link manually, but I had not come across it. I see from the man page that it does some checking, which is good.

Offline

#29 2021-03-09 10:27:10

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Runit

It took a few goes and a few reads of the man page to get it to work, but it seems that the <service> part of the command requires the directory which you have set up. Thus the command I actually gave was :-                                                             

update-service --add /etc/sv/postfix

This seems to set it up nicely.

Offline

#30 2021-03-11 19:49:01

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Runit

In fact

update-service --add /etc/sv/postgresql

also sets up the supervise subdirectories, as necessary. This command does not set up the log file, however, the log/run file which fsmithred presents, above, is very good as it sorts out the log file and only requires the setting up of the service name. If you use the above command and the log/run file, which I have copied here, then this makes the setting up process pretty straightforward.

#!/bin/sh

NAME=postgresql
LOG="/var/log/runit/$NAME"

test -d "$LOG" || mkdir "$LOG" && chown -R _runit-log:adm "$LOG"
exec chpst -u _runit-log svlogd -tt "$LOG"

Geoff

edited <service> to be the same in both examples

Last edited by Geoff 42 (2021-03-31 12:42:48)

Offline

#31 2021-03-11 20:14:41

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Runit

Actually, I think you can simplify the log/run file further :-

#!/bin/sh

NAME=postgresql
LOG="/var/log/runit/$NAME"

install -o _runit-log -g adm -d $LOG
exec chpst -u _runit-log svlogd -tt "$LOG"

Geoff

Offline

#32 2021-03-23 20:09:06

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Runit

I wanted to be able to boot to console on occasion. With sysvinit, I just turn off the display manager in runlevel 3 and put a '3' in the boot command when I want that. It's pretty easy to make a new runlevel in runit.

1. Create a directory in /etc/runit/runsvdir/ named for the new runlevel. Check man pages for the reserved names.
2. Populate it with symlinks to services in /etc/sv/
3. Change to that runlevel with a command or boot to that runlevel with a directive in the boot command.

I did it like this and got the symlinks right without having to make them all manually or script it.

cd /etc/runit/runsvdir
mkdir testt
cp -a default/* testt/
rm testt/lightdm

Add this to the linux line of a boot entry to be able to boot to the new runlevel:

runitdir=testt

This is working correctly.

To change to the new runlevel after a default boot:

runsvchdir testt

This isn't working for my example. It drops to a black screen with a blinking cursor, and I'm in a VM window, so I can't switch tty. It does work when changing to the default runlevel after booting to console.

Offline

#33 2021-03-23 21:29:42

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,251  

Re: Runit

I don't know how runit works, but for the " in a VM window, so I can't switch tty" part of the problem I would suggest that you start qemu with -serial mon:stdio so that the qemu monitor is available in the start terminal. Then use ^C a to "activate" it, and thereafter use verbatim commands like sendkey ctrl-altl-f2 (literally like that) for keys and key combinations that are not avialabable from the keyboard.

Or, you might want to use -serial mon:unix:/tmp/myvm instead to have the console available on the socket /tmp/myvm which you'd connect to with socat - unix-connect:/tmp/myvm or nc -u /tmp/myvm and then operate the qemu monitor through that (in the same way).

Online

#34 2021-03-24 10:25:09

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Runit

Are you using runit under SysVinit or are you using runit-init. With the latter you need to do some setting up of getty. When I do that in a VM under Xen, I have to set up a getty on hvc0 for the console.

Geoff

Offline

#35 2021-03-24 11:03:00

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Runit

I'm using runit-init in chimaera. The getties, acpid and ssh were all set up automatically.  I set up others using advice from this thread.

sendkey ctrl-alt-f2 worked. Thanks!

Also forgot to meniton - if you make a new runlevel and decide to change its name, don't change it while you are in that runlevel, and pay attention to the symlinks in /etc/runit/runsvdir. My system was unbootable because of a dead symlink for default that pointed to the old name.

Offline

#36 2021-03-30 08:23:13

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: Runit

btw, antix did some work on runit : https://www.antixforum.com/forums/topic … lseye-iso/
seems to use antix's own packages, not the debian way of mixing sysvinit/runit..
haven't seen it yet in action, will  be trying the latest iso in the following days :
https://www.antixforum.com/forums/topic … available/

Offline

#37 2021-03-30 14:18:58

andyprough
Member
Registered: 2019-10-19
Posts: 327  

Re: Runit

xinomilo wrote:

btw, antix did some work on runit : https://www.antixforum.com/forums/topic … lseye-iso/
seems to use antix's own packages, not the debian way of mixing sysvinit/runit..
haven't seen it yet in action, will  be trying the latest iso in the following days :
https://www.antixforum.com/forums/topic … available/

antiX has had runit ISO's available for about a year now. It's blazing fast.

Offline

#38 2021-03-31 12:28:41

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Runit

I fired up the antix full runit iso. Here's a list of runscripts they have that are not in Lorenzo's collection. This is as far as I've gotten with it. I haven't tried any of these yet or even looked inside the files.

AntiX has:
bluetooth, connman, ntp, ofono, rpcbind, rsync,
rsyslog, smartmontools, tlp, udevd, ufw

Offline

#39 2021-04-06 17:55:16

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Runit

Update:  I forked live-config to create live-config-runit which sets up console autologin in the live session. The code for that is in /lib/live/config/0190-runit. It works, but I did not replace the live-config init script with runscripts.

Today I tried making runscripts for live-config. It's set up as a one-shot, and it runs, but it does not run early enough. A comment in the init script says it must start before mountkernfs and in my sysvinit system, there is rcS.d/S01live-config which starts before S02mountkernfs. That link is not present in the runit system.

/etc/runit/1 contains:

/lib/runit/run_sysv_scripts '/etc/rcS.d'

So, /lib/runit/run_sysv_scripts will start the init scripts linked in rcS.d.
If the init script is not executable, then live-config does not run until the desktop comes up, so autologin does not happen, and you get a login screen. I've been making the init scripts non-executable, mainly to make it easier to see which ones are managed by runit when I look in /etc/init.d.

Is there another way in runit to make a script run first? I know a runscript can state what must be started before it, but I haven't seen a way to get to say what it must start before. (everything, in this case).

'update-service --remove live-config && chmod +x /etc/init.d/live-config' set it back to the way it was. Now autologin works again in the live-isos I make.

Offline

#40 2021-04-06 22:29:33

Lorenzo
Member
Registered: 2020-03-03
Posts: 46  

Re: Runit

Geoff 42 wrote:

Are you using runit under SysVinit or are you using runit-init. With the latter you need to do some setting up of getty. When I do that in a VM under Xen, I have to set up a getty on hvc0 for the console.

Geoff

Hi,

[ also looking at the other thread  https://dev1galaxy.org/viewtopic.php?id=3628&p=2 ]
The getty-run package ships with a getty-S0 on serial that is disabled by default. Enabling it is usually enough for other virtualization environment like Qemu or Docker, but I've never run Xen so I don't know.. is the getty on hvc0 a requirement for Xen, or anyway a commonly required feature?
If that is the case I can ship a getty on hvc0 too so that the only thing left to do is to enable it.
Let me know!

Thanks,
Lorenzo

Offline

#41 2021-04-06 23:31:11

Lorenzo
Member
Registered: 2020-03-03
Posts: 46  

Re: Runit

fsmithred wrote:

Update:  I forked live-config to create live-config-runit which sets up console autologin in the live session. The code for that is in /lib/live/config/0190-runit. It works, but I did not replace the live-config init script with runscripts.

Today I tried making runscripts for live-config. It's set up as a one-shot, and it runs, but it does not run early enough. A comment in the init script says it must start before mountkernfs and in my sysvinit system, there is rcS.d/S01live-config which starts before S02mountkernfs. That link is not present in the runit system.

If it really need to run that early it need to be a script in /etc/rcS.d/ so keeping the sysvinit scripts is the most straightforward thing to do.
In case the sysvinit comment is wrong, and it can be run later, like after all the stuff in rcS.d, but before certain services (like gettys and login manager) you have two options:

  • ship as a sysv script, but in runlevel 2, and make sure that a runscript with the same name in /etc/sv/ never exists.
       This way it is granted that your script runs before any native runscript (look at the code in stage 2)

  • have it as a oneshot runscript -- you need to convert the script into a proper runscript, and then have the gettys and the
       login manager depends on that service. IMHO it doesn't worth the effort to have runscripts for services where there is nothing
       to supervise (no longrun) as you are adding (uneeded?) complexity to achieve the same result as with a plain sysv script.
       Anyway if someone is curious and wants to experiment, in runit, to do a oneshot, have a line in the run file that does
        ' sv one yourservicename'   otherwise your service will keep restarting when it's done which is pointless.
        Also you need to design some kind of readiness protocol, the easy way is to touch a file into run at the very end of your runscript, like
        ' touch /run/myservice.ok', then write the check file to test for the existence of myservice.ok and exit nonzero if it doesn't exists.
        Then make all services that you want to run after yourservice depends on yourservice with a line like
        ' sv start yourservicename  &&  sv check yourservicename  || exit 1 '
        As you see, if it's not for playing, the sysvinit script it's likely the option you want to chose

Hope the above answer your questions, it case it doesn't just ask again smile
Lorenzo

Offline

#42 2021-04-06 23:35:56

Lorenzo
Member
Registered: 2020-03-03
Posts: 46  

Re: Runit

andyprough wrote:
xinomilo wrote:

btw, antix did some work on runit : https://www.antixforum.com/forums/topic … lseye-iso/
seems to use antix's own packages, not the debian way of mixing sysvinit/runit..
haven't seen it yet in action, will  be trying the latest iso in the following days :
https://www.antixforum.com/forums/topic … available/

antiX has had runit ISO's available for about a year now. It's blazing fast.

As soon as I have some extra time I'll try to provide scripts for those too, except udevd because I'm not 100% sure that it's safe to do all stage 3 with udev not running

Lorenzo

Offline

#43 2021-04-07 09:35:05

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Runit

Lorenzo wrote:

[ also looking at the other thread  https://dev1galaxy.org/viewtopic.php?id=3628&p=2 ]
The getty-run package ships with a getty-S0 on serial that is disabled by default. Enabling it is usually enough for other virtualization environment like Qemu or Docker, but I've never run Xen so I don't know.. is the getty on hvc0 a requirement for Xen, or anyway a commonly required feature?
If that is the case I can ship a getty on hvc0 too so that the only thing left to do is to enable it.
Let me know!

I would not claim to be an expert on Xen, but I do believe that it is necessary to get hvc0 working in order to be able to log in when running Paravirtualised

https://wiki.xenproject.org/wiki/Xen_Co … ms#Console

So, your suggestion sounds good to me.

Geoff

Offline

#44 2021-04-07 13:21:51

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Runit

Lorenzo,

Thanks for the thorough reply. I'm ok with using the scripts in rcS.d - it works fine that way. I might play around with the more advanced configs later.

I was thinking ahead to the future. Sysvinit scripts are disappearing at an alarming rate, and I worry that they won't all land in the new orphan-sysvinit-scripts package.

Offline

#45 2021-06-30 18:00:23

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: Runit

so i've migrated some sysv scripts to Lorenzo's available runscripts.. (using ceres with LXDE currently).

sv status /etc/sv/*
run: /etc/sv/acpid: (pid 1849) 895s; run: log: (pid 1847) 895s
run: /etc/sv/acpi-fakekey: (pid 1820) 895s; run: log: (pid 1819) 895s
run: /etc/sv/cron: (pid 1815) 895s; run: log: (pid 1814) 895s
run: /etc/sv/dbus: (pid 1825) 895s; run: log: (pid 1824) 895s
run: /etc/sv/elogind: (pid 1829) 895s; run: log: (pid 1821) 895s
run: /etc/sv/getty-tty1: (pid 1816) 895s
run: /etc/sv/getty-tty2: (pid 1813) 895s
run: /etc/sv/getty-tty3: (pid 1826) 895s
run: /etc/sv/getty-tty4: (pid 1830) 895s
run: /etc/sv/getty-tty5: (pid 1835) 895s
run: /etc/sv/getty-tty6: (pid 1831) 895s
warning: /etc/sv/getty-ttyS0: unable to open supervise/ok: file does not exist
run: /etc/sv/haveged: (pid 1823) 895s; run: log: (pid 1822) 895s
run: /etc/sv/lightdm: (pid 1828) 895s; run: log: (pid 1827) 895s
run: /etc/sv/openntpd: (pid 1818) 895s; run: log: (pid 1817) 895s
run: /etc/sv/tor: (pid 1833) 895s; run: log: (pid 1832) 895s

had one service error with acpi-fakekey,

/etc/sv/acpi-fakekey/run: 10: exec: -f: not found

worked around it with :

diff runscript-collection/acpi-fakekey/run /etc/sv/acpi-fakekey/run
10c10
< exec $DAEMON -f
---
> exec /usr/sbin/acpi_fakekeyd -f 

another problem i have since migrating elogind/dbus/lightdm scripts to /etc/sv : /etc/init.d/connman doesn't start anymore during boot.. needs to be restarted after boot. so looking to find/create a runit script for connman..

Offline

#46 2021-06-30 18:29:08

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Runit

I'm using the connman runit scripts from the antix collection, and connman seems to be working correctly. I have installed connman, connman-gtk, connman-ui and connman-vpn. The command connman-ui-gtk is in my startup apps. (xfce here)

Offline

#47 2021-07-01 09:06:37

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: Runit

well, i migrated to network-manager and used your runit script from this thread, with some changes.. and it's running fine. (daemon logs still redirect to daemon.log, supervision logs to /var/log/runit/network-manager)
but it also doesnt start at boot, untill i restart iwd (/etc/init.d). so, i probably need another runscript for iwd this time... big_smile
i guess it's going to take some time to migrate everything to runit scripts.. i've been searching around for ideas/ runit scripts, and found this idea interesting :
https://github.com/apayne/supervision-scripts
"distro agnostic", "supervision agnostic" sounds ideal. (to me anyway).

Offline

#48 2021-07-04 18:04:03

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Runit

I'm running Debian buster on a ROCK Pi S as a media renderer front-end for mpd and I've managed to get that and upmpdcli running under supervision:

# sv check mpd
ok: run: mpd: (pid 1223) 561s
# sv check upmpdcli                                         
ok: run: upmpdcli: (pid 2054) 202s
# pstree
runit─┬─runsvdir─┬─runsv─┬─svlogd
      │          │       └─upmpdcli───13*[{upmpdcli}]
      │          └─runsv─┬─mpd───2*[{mpd}]
      │                  └─svlogd
      ├─sshd───sshd───sshd───mksh───pstree
      └─udevd───udevd
#

I followed the instructions in this thread:

  • create /etc/sv/$service/log and the associated (executable) run files

  • symlink the service directory to /etc/service/

  • copy & divert the /etc/init.d/ script

  • symlink /usr/bin/sv to /etc/init.d/

Here are the service run files if anybody's interested:

$ cat /etc/sv/mpd/run                                       
#!/bin/sh -e
if ! [ -d /run/mpd ]; then
        mkdir /run/mpd
        chmod 0755 /run/mpd
        chown -R mpd /run/mpd
fi
exec chpst -u mpd mpd --stdout --no-daemon /etc/mpd.conf
$ cat /etc/sv/upmpdcli/run                                  
#!/bin/sh -e
exec chpst -u upmpdcli upmpdcli -c /etc/upmpdcli.conf
$

The log run files are as described earlier (also executable).


Brianna Ghey — Rest In Power

Offline

Board footer