The officially official Devuan Forum!

You are not logged in.

#1 2020-08-01 21:33:57

macondo
Member
From: Central America
Registered: 2017-06-11
Posts: 52  

Runit

I got antix 19.2 with runit in one of my other partitions, runs great.

In my opinion, is superior and faster than the other init systems.

The Devuan devs should incorporate it soon.


Desktop Dual Core 8 GB RAM - Devuan Ceres - Slackware Current - Grub - JWM
“Just because you're paranoid doesn't mean they aren't after you.” ― Joseph Heller, Catch-22

Offline

#2 2020-08-01 21:45:50

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

Re: Runit

Already done. It will be an installation choice in the beowulf point-release. Until then, you have to add it manually after the system is installed.

Offline

#3 2020-08-01 21:47:10

brocashelm
Member
Registered: 2020-06-29
Posts: 112  

Re: Runit

Runit is excellent and can already be used with Devuan since Beowulf.

Here's a quick guide:

Head_on_a_Stick wrote:

This guide shows how to use runit-init as PID1 in Devuan, it is primarily aimed at Jesse from Distrowatch smile

First, instal the runit-init package:

# apt install runit-init

APT will ask for a specific confirmation for the operation because replacing the init system is far from trivial, type in the required authorisation to install the package.

Next, reboot into runit-init. Check it has worked with

cat /proc/1/comm

The output should be runit.

That's it!

EDIT: if a display manager is not required then add the user to the input group to allow access to the keyboard &c:

# gpasswd -a $USER input

Offline

#4 2021-01-25 09:42:13

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Runit

Installation medium: Beowulf netinstall
Host: a headless vps somewhere north europe !

I installed runit .
But only gettys run under runsv . Does that mean that apache , rsyslogd , sshd , dhclient as services do not have a runit ''interface''?
----------------------
I found a page with runit runscripts scripts. Should i use those?

-----------------------

Ok, they helped me at #devuan irc.
If i got it, runit defaults in sysvinit when it wont find runit scripts.

Last edited by chomwitt (2021-01-25 13:40:38)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#5 2021-01-26 09:49:44

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Runit

# pstree
runit─┬─apache2───2*[apache2───26*[{apache2}]]
      ├─avahi-daemon───avahi-daemon
      ├─cron
      ├─cups-browsed───2*[{cups-browsed}]
      ├─cupsd
      ├─dbus-daemon
      ├─dhclient
      ├─elogind-daemon
      ├─rsyslogd───3*[{rsyslogd}]
      ├─runsvdir─┬─5*[runsv───fgetty]
      │          └─runsv───bash
      ├─saned───saned
      ├─sshd───sshd───bash───pstree
      └─udevd

So only fgetty is supervised by runsv processes.
Trying to found how runit starts the other processes.

So i am pondering if runit cant handle a process , and it uses sysvinit script to start it , that means that this process hasnt a supervisor and if it fails it wont start automatically ?

Last edited by chomwitt (2021-01-26 10:11:37)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#6 2021-01-26 15:57:54

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

Re: Runit

chomwitt wrote:

if runit cant handle a process , and it uses sysvinit script to start it , that means that this process hasnt a supervisor and if it fails it wont start automatically ?

I think runit relies on the same PID file hack that sysvinit uses for processes not supervised by runsv.


Brianna Ghey — Rest In Power

Offline

#7 2021-02-09 09:29:55

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

Re: Runit

Hi (runit maintainer here),

If i got it, runit defaults in sysvinit when it wont find runit scripts.

During boot it first run all sysv scripts in runlevel 2, but it skips those for which a native runscript that matches the basename exists.
Then it starts all native runscripts that are enabled.
For example if you have a /etc/sv/ssh runit service, than the SNNssh sysv service will be skipped.

----------------------
I found a page with runit runscripts scripts. Should i use those?

-----------------------

those are quite old, but still a good starting point for experimenting.
I maintain a collection https://salsa.debian.org/runit-team/run … collection
but please everybody, CAUTION*, those are meant to be used with runit>=2.1.2-36 and anyway are somehow experimental.
I plan to upload a catchall package that will properly install those (and more) runscripts into the system, but
it's unrealistic to expect to see it land into unstable before summer 2021.

last thing, for the brave souls that are willing to experiment, i accept requests for adding new runscripts at the condition that the person that does the request is available to test and report if it's working

Best,
Lorenzo

*especially if you are running a desktop environment, you either want to have dbus, elogind and sddm|lightdm|slim|etc.. all as runscripts or all as sysv script. Mixing wont work an you'll end up with a VT login.

Offline

#8 2021-02-09 14:47:47

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

Re: Runit

Lorenzo, thanks for the info, and for your work with runit on debian smile

this might also be useful for testers : https://salsa.debian.org/runit-team/run … ian/README
maybe a similar README can go to runscript-collection (?)

Last edited by xinomilo (2021-02-09 15:03:29)

Offline

#9 2021-02-10 17:11:38

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

Re: Runit

This doesn't seem to be working for me, and I can't figure out what I'm doing wrong. I followed the directions in the README and set up cron and then anacron to work with runit. I can't tell whether it's running or not because it looks like I'm getting contradictory information.

Also, I made a test script that dumps the time into a file in user's home and put it in /etc/cron.hourly/. It works when I run it manually but does not run every hour.

sv says they are down but shows the pid and how long they've been running.

root@chimaera-2:/home/user# sv status cron
down: cron: 24s, normally up; run: log: (pid 2038) 24s
root@chimaera-2:/home/user# sv status anacron
down: anacron: 34s, normally up; run: log: (pid 2042) 34s

Attempt to bring them up makes no change.

root@chimaera-2:/home/user# sv up anacron
root@chimaera-2:/home/user# sv up cron
root@chimaera-2:/home/user# sv status cron
down: cron: 4s, normally up; run: log: (pid 2038) 59s
root@chimaera-2:/home/user# sv status anacron
down: anacron: 14s, normally up; run: log: (pid 2042) 63s

'ps ax' says they are running but pstree does not.

root@chimaera-2:/home/user# ps ax | grep cron
 2033 ?        Ss     0:00 runsv cron
 2034 ?        Ss     0:00 runsv anacron
 2038 ?        S      0:00 logger -p daemon notice -t runsv-cron
 2042 ?        S      0:00 svlogd -tt /var/log/runit/anacron

      ├─runsvdir─┬─6*[runsv───getty]
      │          ├─runsv─┬─acpid
      │          │       └─svlogd
      │          ├─runsv─┬─sshd
      │          │       └─svlogd
      │          ├─runsv───logger
      │          └─runsv───svlogd

What next?

Offline

#10 2021-02-11 10:26:27

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

Re: Runit

sv says they are down but shows the pid and how long they've been running.

root@chimaera-2:/home/user# sv status cron
down: cron: 24s, normally up; run: log: (pid 2038) 24s
root@chimaera-2:/home/user# sv status anacron
down: anacron: 34s, normally up; run: log: (pid 2042) 34s

Look carefully at the output: it says that cron is down since 24s; the appendant log service is running with PID 2038 since 24s.
when it's working sv will show the following

~# sv s cron
run: cron: (pid 6920) 969s; run: log: (pid 6919) 969s

'ps ax' says they are running but pstree does not.

'ps ax' shows the runsv monitor, but not the cron process. The correct output would be

~# ps ax | grep cron
[...]
 6918 ?        Ss     0:00 runsv cron
 6919 ?        S      0:00 logger -p daemon notice -t cron-run
 6920 ?        S      0:00 /usr/sbin/cron -f
[...]

So cron it's definitely not working for you ( the same script works for me so it's hard to tell what's wrong from here);
Anacron.. it's possibly working (see below)

What next?

If you have more time to spend in debugging I suggest the following:

Anacron:
it's a "one shot",  it goes up and looks if there are tasks to do; when it's done it goes down. To check if it's working look at the appendant log

# cat /var/log/runit/anacron/current

if it works you'll see output similar to

2021-02-10_09:11:23.94073 Invoke-run: Starting anacron
2021-02-10_09:11:23.94277 Anacron 2.3 started on 2021-02-10
2021-02-10_09:11:23.94715 Normal exit (0 jobs run)
2021-02-10_09:11:23.96108 invoke-run: anacron stopped
2021-02-11_07:02:16.02720 Invoke-run: Starting anacron
2021-02-11_07:02:16.03099 Anacron 2.3 started on 2021-02-11
2021-02-11_07:02:16.03300 Will run job `cron.daily' in 5 min.
2021-02-11_07:02:16.03301 Jobs will be executed sequentially
2021-02-11_07:07:15.56730 Job `cron.daily' started
2021-02-11_07:19:35.70168 Job `cron.daily' terminated
2021-02-11_07:19:35.70172 Normal exit (1 job run)
2021-02-11_07:19:35.70406 invoke-run: anacron stopped

Cron:

  • try to comment the 'set -e' line in the run script and then do a full restart with

    sv e cron

    if it's working there is some command that is failing for you in the script, before the exec line.

  • you can turn on the verbose and debug mode in /etc/default/runit
    verbose prints start and stop marker in logs (like 'invoke-run: starting cron');
    debug prints in log the exit status of the run script; it can be cron's exit status or an shell exist status, it depends if it reaches the exec line or fails earlier (search for 'invoke-run: cron : run exit code is ')
    Cron does not have it's own appendant log service because it only logs to syslog: search in the system log

  • there is a 'supervision tree log'. text there does not mean necessary an error, and is about every supervised service, but
    it's worth looking

    ~# ps ax | grep runsvdir
     1781 ?        Ss     0:00 runsvdir -P /etc/service log: ...........................................................................................................................................................................................................................................................................................................................................................................................................

    look for text in the dots, there is none for me right now

  • As a last resort try to run cron manually, to check if there is an issue with cron in your system

    # /usr/sbin/cron -f

For now i don't have other ideas..

Offline

#11 2021-02-11 11:08:02

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

Re: Runit

Just for the records, I'm not trying to sell something that I don't use or that it's completely untested; from the system that i'm using for live testing

~$ pstree
runit─┬─agent───2*[{agent}]
      ├─alsa_in───3*[{alsa_in}]
      ├─alsa_out───3*[{alsa_out}]
      ├─at-spi-bus-laun─┬─dbus-daemon
      │                 └─3*[{at-spi-bus-laun}]
      ├─auditd───{auditd}
      ├─dbus-daemon
      ├─dbus-launch
      ├─dconf-service───2*[{dconf-service}]
      ├─dhclient───3*[{dhclient}]
      ├─firefox-esr─┬─Privileged Cont───24*[{Privileged Cont}]
      │             ├─Web Content───27*[{Web Content}]
      │             ├─Web Content───17*[{Web Content}]
      │             ├─WebExtensions───22*[{WebExtensions}]
      │             └─64*[{firefox-esr}]
      ├─gvfsd───2*[{gvfsd}]
      ├─kaccess───2*[{kaccess}]
      ├─kglobalaccel5───2*[{kglobalaccel5}]
      ├─polkitd───2*[{polkitd}]
      ├─qjackctl─┬─jackd───4*[{jackd}]
      │          └─8*[{qjackctl}]
      ├─qterminal─┬─bash───pstree
      │           └─6*[{qterminal}]
      ├─runsvdir─┬─runsv─┬─dbus-daemon
      │          │       └─svlogd
      │          ├─2*[runsv─┬─socklog]
      │          │          └─svlogd]
      │          ├─5*[runsv───fgetty]
      │          ├─runsv─┬─slim─┬─Xorg───9*[{Xorg}]
      │          │       │      └─lxqt-session─┬─lxqt-notificati───6*[{lxqt-notificati}]
      │          │       │                     ├─lxqt-panel───6*[{lxqt-panel}]
      │          │       │                     ├─lxqt-policykit-───4*[{lxqt-policykit-}]
      │          │       │                     ├─lxqt-powermanag───2*[{lxqt-powermanag}]
      │          │       │                     ├─lxqt-runner───2*[{lxqt-runner}]
      │          │       │                     ├─openbox───2*[{openbox}]
      │          │       │                     ├─ssh-agent
      │          │       │                     └─2*[{lxqt-session}]
      │          │       └─svlogd
      │          ├─2*[runsv]
      │          ├─runsv─┬─acpid
      │          │       └─svlogd
      │          ├─runsv─┬─cat
      │          │       └─svlogd
      │          ├─runsv─┬─gdomap
      │          │       └─svlogd
      │          ├─2*[runsv───svlogd]
      │          ├─runsv─┬─git-daemon
      │          │       └─svlogd
      │          ├─runsv─┬─ntpd───ntpd───ntpd
      │          │       └─svlogd
      │          ├─runsv─┬─postfix-script───master─┬─pickup
      │          │       │                         └─qmgr
      │          │       └─svlogd
      │          ├─runsv─┬─atd
      │          │       └─svlogd
      │          ├─runsv─┬─cupsd
      │          │       └─logger
      │          ├─runsv─┬─dnsmasq
      │          │       └─svlogd
      │          ├─runsv─┬─php-fpm7.4───2*[php-fpm7.4]
      │          │       └─svlogd
      │          ├─runsv─┬─svlogd
      │          │       └─tor
      │          ├─runsv─┬─mdadm
      │          │       └─svlogd
      │          ├─runsv─┬─haveged
      │          │       └─svlogd
      │          ├─runsv─┬─sshd
      │          │       └─svlogd
      │          ├─runsv─┬─mysqld───7*[{mysqld}]
      │          │       └─svlogd
      │          ├─runsv───run
      │          ├─runsv─┬─apache2───5*[apache2]
      │          │       └─logger
      │          ├─runsv─┬─preload
      │          │       └─svlogd
      │          ├─runsv─┬─lircd───sh
      │          │       └─svlogd
      │          ├─runsv─┬─elogind
      │          │       └─logger
      │          ├─runsv─┬─svlogd
      │          │       └─w───w
      │          └─runsv─┬─cron
      │                  └─logger
      ├─smartd
      ├─superkaramba
      ├─systemd-udevd
      ├─udisksd───4*[{udisksd}]
      ├─upowerd───2*[{upowerd}]
      └─xscreensaver───xscreensaver-sy

I'm working to provide ~50 services picked from the most popular (popcon) and the one that I think are used in servers.
Anyway live testing it is what it is, and I don't use all of 50 services in my pc of course, so reports of failure or success  from people that actually use a service are very useful to determine which services are safe to include in a catch all package and which are not and need more work.

Lorenzo

Offline

#12 2021-02-11 11:10:39

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

Re: Runit

Lorenzo wrote:

from the system that i'm using for live testing

If you don't mind me asking, which desktop are you using?

Thank you very much for your efforts, they are very much appreciated.


Brianna Ghey — Rest In Power

Offline

#13 2021-02-11 11:21:45

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

Re: Runit

also tried a service from collection : haveged (thought i pick a simple one for starters), but not working succesfully..
gets timeout,

# sv start haveged
timeout: down: haveged: 7s, normally up

log :

2021-02-11_11:01:16.37237 invoke-run: ERROR -1 in haveged: runscript didn't exit normally
2021-02-11_11:01:16.37276 invoke-run: haveged : run exit code is -1
2021-02-11_11:01:16.37279 invoke-run: haveged stopped

using devuan ceres, amd64. also tried removing "set -e" , but no luck..
in general where should we report things like that?

Head_on_a_Stick wrote:
Lorenzo wrote:

from the system that i'm using for live testing

If you don't mind me asking, which desktop are you using?

looks like lxqt/openbox ...

Last edited by xinomilo (2021-02-11 11:22:34)

Offline

#14 2021-02-11 12:43:42

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

Re: Runit

Yes, of course, silly me. Thanks and sorry for the noise.


Brianna Ghey — Rest In Power

Offline

#15 2021-02-11 13:12:47

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

Re: Runit

also tried a service from collection : haveged (thought i pick a simple one for starters), but not working succesfully..
gets timeout,

    # sv start haveged
    timeout: down: haveged: 7s, normally up

log :

    2021-02-11_11:01:16.37237 invoke-run: ERROR -1 in haveged: runscript didn't exit normally
    2021-02-11_11:01:16.37276 invoke-run: haveged : run exit code is -1
    2021-02-11_11:01:16.37279 invoke-run: haveged stopped

Ah! I've squeezed my brain a over that -1 a little bit and I think i've found the culprit:

please remove the symlink and the diversion on the sysv script in /etc/init.d/haveged (restore the original script, no symlink to sv);

rm /etc/init.d/haveged
dpkg-divert --remove /etc/init.d/haveged

then restart haveged

sv e haveged

Is it working now?

Offline

#16 2021-02-11 15:09:15

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

Re: Runit

Lorenzo wrote:

Is it working now?

well yes, it is!

but error could be my mistake, since i didn't originally do "dpkg-divert --add /etc/init.d/haveged" when i first added the script.. somehow i skipped/missed that part from README... (?)
( `dpkg-divert --remove` couldn't find anything to remove, and made me wonder... )
----
will probably try some more scripts whenever i get more free time.. thanks for the fast reply..

Offline

#17 2021-02-11 16:21:10

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

Re: Runit

Lorenzo wrote:

Just for the records, I'm not trying to sell something that I don't use or that it's completely untested;

Just for the record, I don't use runit, but I'm commited enough to the idea of diversity in the ecosystem that I'm willing to do some testing or make it easy for other to test. Last year I made a live-iso based on devuan beowulf that uses runit so that people could try it. I know there are a few people using runit in devuan.

I made another live-iso based on chimaera (bullseye) but I haven't uploaded it yet. That might happen soon.

About my issues:
Skip to the end to see that it's fixed. I used the advice you gave to xinomilo for haveged.

Longer version:
I switched it back to sysvinit for cron and anacron and managed to get my test script to work.
Then switched it back to runit, commented set -e and added set -x (the latter did nothing) and also set VERBOSE and DEBUG. Then I started cron manually with # /usr/sbin/cron -f

Got the following:

2021-02-11_13:54:02.22150 invoke-run: ERROR -1 in anacron: runscript didn't exit normally
2021-02-11_13:54:02.22156 invoke-run: anacron : run exit code is -1
2021-02-11_13:54:02.22157 invoke-run: anacron stopped
2021-02-11_13:59:00.98343 invoke-run: ERROR -1 in anacron: runscript didn't exit normally
2021-02-11_13:59:00.98348 invoke-run: anacron : run exit code is -1
2021-02-11_13:59:00.98349 invoke-run: anacron stopped

# ps ax | grep runsvdir
 1384 ?        Ss     0:01 runsvdir -P /etc/service log: ...........................................................................................................................................................................................................................................................................................................................................................................................................
 4373 pts/0    S+     0:00 grep runsvdir

# sylog
Feb 11 13:43:13 chimaera-2 runsv-cron: invoke-run: ERROR -1 in cron: runscript didn't exit normally
Feb 11 13:52:59 chimaera-2 runsv-cron: invoke-run: ERROR -1 in cron: runscript didn't exit normally
Feb 11 13:52:59 chimaera-2 runsv-cron: invoke-run: cron : run exit code is -1
Feb 11 13:52:59 chimaera-2 runsv-cron: invoke-run: cron stopped
Feb 11 13:54:16 chimaera-2 runsv-cron: invoke-run: ERROR -1 in cron: runscript didn't exit normally
Feb 11 13:54:16 chimaera-2 runsv-cron: invoke-run: cron : run exit code is -1
Feb 11 13:54:16 chimaera-2 runsv-cron: invoke-run: cron stopped

Saw your advice to xinomilo and did the same -
- remove the symlinks in /etc/init.d/
- dpkg-divert --remove /etc/init.d/<service>
- sv e cron

# sv status cron
run: cron: (pid 4615) 696s; run: log: (pid 4614) 696s

Thanks!

Offline

#18 2021-02-26 04:30:20

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Runit

Im a bit confused on how to check runit scripts ? Im fairly new at this so please forgive any mistakes, coming from voidlinux is where my confusion starts.

So i installed a fresh copy of debian bullseye just to see how runit-init works (just as a test bed, i aim to do this with devuan as well) and it is working well except i had to create run scripts for NetworkManager to make it work (or did i not have to?). Having researched this a it more would it be right that to start, stop and check status of init scripts the way to do this would be like so? So this is using sysv-rc style scripts and how these transfer over to runit? So there is a separation for now on sysv scripts and native runit scripts?

sudo /etc/init.d/lightdm status # start and stop etc?

For the network manager run script i used this info from here https://kchard.github.io/runit-quickstart/ as couldnt see one in /etc/init.d/

Are these scripts ok and are they missing anything, in the right locations?

run..

/etc/runit/NetworkManager/run
#!/bin/sh -e
exec 2>&1
exec chpst -u root NetworkManager

log..

/etc/runit/NetworkManager/log/run
#!/bin/sh
exec chpst -u root svlogd -tt /var/log/NetworkManager/

Then finally

# ln -s /etc/runit/NetworkManager /etc/service

Can confirm that NetworkManager is working.

pstree

~$ pstree
runit─┬─ModemManager───2*[{ModemManager}]
      ├─NetworkManager───2*[{NetworkManager}]
      ├─at-spi-bus-laun─┬─dbus-daemon
      │                 └─3*[{at-spi-bus-laun}]
      ├─at-spi-bus-laun───3*[{at-spi-bus-laun}]
      ├─at-spi2-registr───2*[{at-spi2-registr}]
      ├─avahi-daemon───avahi-daemon
      ├─colord───2*[{colord}]
      ├─cron
      ├─3*[dbus-daemon]
      ├─2*[dbus-launch]
      ├─dconf-service───2*[{dconf-service}]
      ├─elogind-daemon
      ├─gnome-keyring-d───3*[{gnome-keyring-d}]
      ├─gpg-agent
      ├─gvfs-udisks2-vo───3*[{gvfs-udisks2-vo}]
      ├─gvfsd─┬─gvfsd-trash───2*[{gvfsd-trash}]
      │       └─2*[{gvfsd}]
      ├─gvfsd-metadata───2*[{gvfsd-metadata}]
      ├─lightdm─┬─Xorg───9*[{Xorg}]
      │         ├─lightdm─┬─xfce4-session─┬─Thunar───2*[{Thunar}]
      │         │         │               ├─applet.py
      │         │         │               ├─light-locker───3*[{light-locker}]
      │         │         │               ├─nm-applet───3*[{nm-applet}]
      │         │         │               ├─polkit-gnome-au───2*[{polkit-gnome-au}]
      │         │         │               ├─ssh-agent
      │         │         │               ├─xfce4-notifyd───2*[{xfce4-notifyd}]
      │         │         │               ├─xfce4-panel─┬─panel-10-notifi───2*[{panel-10-notifi}]
      │         │         │               │             ├─panel-14-action───2*[{panel-14-action}]
      │         │         │               │             ├─panel-6-systray───2*[{panel-6-systray}]
      │         │         │               │             ├─panel-8-pulseau───2*[{panel-8-pulseau}]
      │         │         │               │             ├─panel-9-power-m───2*[{panel-9-power-m}]
      │         │         │               │             └─2*[{xfce4-panel}]
      │         │         │               ├─xfce4-power-man───2*[{xfce4-power-man}]
      │         │         │               ├─xfdesktop───2*[{xfdesktop}]
      │         │         │               ├─xfsettingsd───2*[{xfsettingsd}]
      │         │         │               ├─xfwm4───6*[{xfwm4}]
      │         │         │               ├─xiccd───2*[{xiccd}]
      │         │         │               └─2*[{xfce4-session}]
      │         │         └─2*[{lightdm}]
      │         └─2*[{lightdm}]
      ├─polkitd───2*[{polkitd}]
      ├─pulseaudio───2*[{pulseaudio}]
      ├─rsyslogd───3*[{rsyslogd}]
      ├─rtkit-daemon───2*[{rtkit-daemon}]
      ├─runsvdir─┬─6*[runsv───fgetty]
      │          └─runsv───svlogd
      ├─saned───saned
      ├─systemd-udevd
      ├─udisksd───4*[{udisksd}]
      ├─upowerd───2*[{upowerd}]
      ├─wpa_supplicant
      ├─x-www-browser─┬─Privileged Cont───23*[{Privileged Cont}]
      │               ├─2*[Web Content───23*[{Web Content}]]
      │               ├─2*[Web Content───24*[{Web Content}]]
      │               ├─Web Content───17*[{Web Content}]
      │               ├─WebExtensions───22*[{WebExtensions}]
      │               └─61*[{x-www-browser}]
      ├─xfce4-terminal─┬─bash───pstree
      │                └─2*[{xfce4-terminal}]
      └─xfconfd───2*[{xfconfd}]

Anyhow, thanks for making runit available on devuan/debian.

Last edited by dice (2021-02-26 04:41:53)

Offline

#19 2021-02-26 13:07:29

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

Re: Runit

@dice -

It looks like n-m is not being managed by runit. Look at what's under runsvdir -  just fgetty.
Try sv status network-manager and compare to sv status fgetty

You put your NetworkManager directory in /etc/runit. My run dirs are in /etc/runit/runsvdir. (see tree below)

My run dirs are named the same as the init script. I don't know if that matters. So maybe you should have /etc/runit/runsvdir/network-manager.

I didn't examine the content of your run script or review the procedure I used, so I can't comment on either. I'm new at this, too. I can try it with n-m later today or this weekend.

Here's my tree:

# tree /etc/runit
/etc/runit
├── 1
├── 2
├── 3
├── ctrlaltdel
└── runsvdir
    ├── current -> /etc/runit/runsvdir/default
    ├── default
    │   ├── acpid -> /etc/sv/acpid
    │   ├── anacron -> /etc/sv/anacron
    │   ├── cron -> /etc/sv/cron
    │   ├── getty-tty1 -> ../../../sv/getty-tty1
    │   ├── getty-tty2 -> /etc/sv/getty-tty2
    │   ├── getty-tty3 -> /etc/sv/getty-tty3
    │   ├── getty-tty4 -> /etc/sv/getty-tty4
    │   ├── getty-tty5 -> /etc/sv/getty-tty5
    │   ├── getty-tty6 -> /etc/sv/getty-tty6
    │   ├── haveged -> /etc/sv/haveged
    │   └── ssh -> /etc/sv/ssh
    ├── single
    │   └── sulogin
    │       └── run
    ├── solo
    │   ├── getty-tty1 -> ../../../sv/getty-tty1
    │   └── getty-ttyS0 -> ../../../sv/getty-ttyS0
    └── svmanaged

20 directories, 5 files

Here's some pstree. My n-m is started by runit but not managed by it.

runit─┬─NetworkManager───2*[{NetworkManager}]
      ├─acpi_fakekeyd
      ├─at-spi-bus-laun─┬─dbus-daemon
      │                 └─2*[{at-spi-bus-laun}]
      ├─at-spi2-registr───2*[{at-spi2-registr}]
      ├─blueman-tray───2*[{blueman-tray}]
      ├─bluetoothd
      ├─2*[dbus-daemon]
      ├─dbus-launch

      ├─runsvdir─┬─6*[runsv───getty]
      │          ├─runsv─┬─acpid
      │          │       └─svlogd
      │          ├─runsv─┬─sshd───sshd───sshd───bash───pstree
      │          │       └─svlogd
      │          ├─runsv─┬─cron
      │          │       └─logger
      │          ├─runsv─┬─haveged
      │          │       └─svlogd
      │          └─runsv───svlogd

Offline

#20 2021-02-26 13:55:50

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Runit

Thanks fsmithred, im not on the system with runit at present but will check it tommorow.

I should probably set up a devuan system with runit-init before i say anything more. My interest here is on how far debian has got in regards to init diversity by using debian media, and it is looking promising.

Offline

#21 2021-02-26 14:54:57

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

Re: Runit

Hi all,

Are these scripts ok and are they missing anything, in the right locations?

Runit services in Debian and Devuan are stored under /etc/sv/ so you want to have for example

/etc/sv/network-manager/run

My run dirs are named the same as the init script. I don't know if that matters.

Yes it matters: during the boot sequence a script starts all sysv script that are enabled in Sysv runlevel 2, but when
a runscripts in /etc/sv/ with the same name exists the script is skipped (as it will be managed by runit).
Having multiple instances of the same daemon can cause conflicts or other weird malfunctioning, I suggest to keep the
same name of the sysv script.

About the runscript:

#!/bin/sh -e
exec 2>&1
exec chpst -u root NetworkManager

I don't use networkmanager, so I'm not able to test it but there are a couple of things that seems wrong to me:

You need the --no-daemon option: as a general rule runit can't supervise a service that runs in background (or daemonize), you need to use an option to run in foreground;

Is there a reason why are you using chpst -u root ? The service is already run as root, there no need to use chpst here.
Same for the log service.

There is also another problem, network manager is a Dbus-service, so you technically need to specify the dependency of this service on Dbus. In your test case will work also without the dependency, because dbus is already started as sysv service, but if you are going to have dbus managed by runit, this one will fail to start.

Something like the following could work ( not tested)

#!/bin/sh -e
## uncomment the following if you have dbus as runit service
#sv start dbus  &&  sv check dbus  ||  exit 1
exec 2>&1
exec /usr/sbin/NetworkManager --no-daemon

Hope this helps,
Lorenzo

Offline

#22 2021-02-26 15:24:58

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Runit

Thankyou Lorenzo, i will go over this tomorrow and report back. Much to be learnt.

Offline

#23 2021-02-26 23:47:53

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

Re: Runit

Lorenzo, thanks for helping us with this and thanks for doing it.

Lorenzo wrote:

Hi all,
Something like the following could work ( not tested)

#!/bin/sh -e
## uncomment the following if you have dbus as runit service
#sv start dbus  &&  sv check dbus  ||  exit 1
exec 2>&1
exec /usr/sbin/NetworkManager --no-daemon

Hope this helps,
Lorenzo

Tested. And it does work just as it is. I haven't tried dbus yet.

1. /etc/init.d/network-manager stop
2.  copy files into /etc/sv/network-manager
3. update-service --add network-manager
4. (maybe)  sv start network-manager    Not sure if you need to do this. I started/stopped and check status a bunch of times until I was able to get the logging out of the syslog.

Here are the files I used:

network-manager/run

#!/bin/sh -e
## uncomment the following if you have dbus as runit service
#sv start dbus && sv check dbus || exit 1
exec 2>&1
exec /usr/sbin/NetworkManager --no-daemon

network-manager/log/run

#!/bin/sh
set -e

NAME=network-manager
LOG="/var/log/runit/$NAME"

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

network-manager/finish

#!/bin/sh
set -e

. /lib/runit/finish-default "$@"

I also set up mdadm with runit. I used the same procedure as above with the sample runscripts but had to change the last line in mdadm/log/run from a hard-coded log file to "$LOG". That file looks like this now:

#!/bin/sh

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

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

Offline

#24 2021-02-27 11:59:59

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: Runit

Looks interesting fsmithred, i will have to take some time to look through the sysv init scripts and the runit scripts before i go trying to convert to native runit scripts. When i have the time i might set up a simple dwm X setup with just the basic init processes and start small first and see how i go.

Offline

#25 2021-02-28 10:54:00

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

Re: Runit

I'm not sure if I got the logging right. NetworkManager is working, but puts very little in the runit logs and puts more in syslog. It was spamming the syslog with everything it did until I added --log-level=ERR to the start command.

Also, mdadm gives an error (-1) when it stops. But it seems to be running. I don't have any raid array to test it right now.

pstree:

      ├─runsvdir─┬─6*[runsv───getty]
      │          ├─runsv─┬─acpid
      │          │       └─svlogd
      │          ├─runsv─┬─NetworkManager───2*[{NetworkManager}]
      │          │       └─svlogd
      │          ├─runsv─┬─sshd
      │          │       └─svlogd
      │          ├─runsv─┬─cron
      │          │       └─logger
      │          ├─runsv─┬─mdadm
      │          │       └─svlogd
      │          ├─runsv─┬─haveged
      │          │       └─svlogd
      │          └─runsv───svlogd

NetworkManager messages in syslog:
# on stopping network-manager:

Feb 28 02:25:08 chimaera-2 dbus-daemon[1506]: [system] Activating service name='org.freedesktop.nm_dispatcher' requested by ':1.35' (uid=0 pid=2919 comm="/usr/sbin/NetworkManager --no-daemon --log-level=E") (using servicehelper)
Feb 28 02:25:08 chimaera-2 dbus-daemon[1506]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'

# on starting network-manager

Feb 28 02:26:50 chimaera-2 dbus-daemon[1506]: [system] Activating service name='org.freedesktop.nm_dispatcher' requested by ':1.38' (uid=0 pid=3006 comm="/usr/sbin/NetworkManager --no-daemon --log-level=E") (using servicehelper)
Feb 28 02:26:50 chimaera-2 dbus-daemon[1506]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'

network-manager runit log on exit:

2021-02-28_02:25:09.02206 invoke-run: network-manager : run exit code is 0
2021-02-28_02:25:09.02209 invoke-run: network-manager stopped

mdadm runit log error on exit:

2021-02-28_01:26:40.87497 invoke-run: ERROR -1 in mdadm: runscript didn't exit normally
2021-02-28_01:26:40.87504 invoke-run: mdadm : run exit code is -1
2021-02-28_01:26:40.87505 invoke-run: mdadm stopped

network-manager/log/run

#!/bin/sh
set -e

NAME=network-manager
LOG="/var/log/runit/$NAME"

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

mdadm/log/run

#!/bin/sh

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

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

Offline

Board footer