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: 388  

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: 1,846  

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: 388  

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: 388  

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: 388  

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: 388  

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: 1,846  

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: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 542  

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

Offline

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

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

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: 1,846  

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
Member
Registered: 2017-07-02
Posts: 165  

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: 30  

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.


Primary Computer - Commodore 64: Processor - MOS 6510/8500, 1.023MHz; Memory - 64kb RAM, 20kB ROM - 8k BASIC V2, 8k Kernel, 4k Character ROM; Display output - 320x200, 16 colours; OS - BASIC V2.0; Weight: 1.8kg

Offline

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

fsmithred
Administrator
Registered: 2016-11-25
Posts: 1,846  

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: 1,846  

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: 12  

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: 12  

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: 12  

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: 388  

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: 1,846  

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

Board footer