Discussion:
LXC Slackware Container - runit
(too old to reply)
spaceman
2018-09-17 13:01:01 UTC
Permalink
Hi,

Using a stock LXC Slackware container can anyone tell me why I cannot do
this:

# /etc/rc.d/rc.local

/usr/bin/runsvdir /services &

If I remove the ampersand it runs fine, but with the ampersand it fails
to run the services directory.

I'm thinking there is something missing from the container that runit
needs but cannot think what it is. I checked depedencies using ldd
and no libraries are missing. I've also commented the restrictions
(lxc.cap.drop) in the lxc config but it does nothing.

It just doesn't run with no error message to explain why. I know runit
works with Slackware as the host uses both.

Love Slackware and LXC but need process supervision. Don't particularly
want to use runit for init and boot as that would require a lot of work.

Regards,
spaceman
Serge E. Hallyn
2018-09-17 18:39:13 UTC
Permalink
Post by spaceman
Hi,
Using a stock LXC Slackware container can anyone tell me why I cannot do
# /etc/rc.d/rc.local
/usr/bin/runsvdir /services &
Is it pid 1 doing this? Does it go on to exit?
Post by spaceman
If I remove the ampersand it runs fine, but with the ampersand it fails
to run the services directory.
I'm thinking there is something missing from the container that runit
needs but cannot think what it is. I checked depedencies using ldd
and no libraries are missing. I've also commented the restrictions
(lxc.cap.drop) in the lxc config but it does nothing.
It just doesn't run with no error message to explain why. I know runit
works with Slackware as the host uses both.
Love Slackware and LXC but need process supervision. Don't particularly
want to use runit for init and boot as that would require a lot of work.
Regards,
spaceman
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
spaceman
2018-09-18 11:29:45 UTC
Permalink
Serge E. Hallyn wrote:

Hi,
Post by Serge E. Hallyn
Post by spaceman
# /etc/rc.d/rc.local
/usr/bin/runsvdir /services &
Is it pid 1 doing this? Does it go on to exit?
pid 1 for the container is init which sets off the boot process and
operates normally and doesn't exit. Don't really understand the
question.

Regards,
spaceman
Serge E. Hallyn
2018-09-18 17:18:04 UTC
Permalink
Post by spaceman
Hi,
Post by Serge E. Hallyn
Post by spaceman
# /etc/rc.d/rc.local
/usr/bin/runsvdir /services &
Is it pid 1 doing this? Does it go on to exit?
pid 1 for the container is init which sets off the boot process and
operates normally and doesn't exit. Don't really understand the
question.
"pid 1 sets off the boot process" != "pid 1 forks+execs
/usr/bin/runsvdir /services & and then exits".

If the latter happens, then you'll need to have pid 1 stick around
somehow. When pid 1 exits, the container gets killed.
Matteo Bernardini
2018-09-18 10:27:21 UTC
Permalink
Il giorno lun 17 set 2018 alle ore 19:08 spaceman
Post by spaceman
Hi,
Using a stock LXC Slackware container can anyone tell me why I cannot do
# /etc/rc.d/rc.local
/usr/bin/runsvdir /services &
If I remove the ampersand it runs fine, but with the ampersand it fails
to run the services directory.
I'm thinking there is something missing from the container that runit
needs but cannot think what it is. I checked depedencies using ldd
and no libraries are missing. I've also commented the restrictions
(lxc.cap.drop) in the lxc config but it does nothing.
It just doesn't run with no error message to explain why. I know runit
works with Slackware as the host uses both.
Love Slackware and LXC but need process supervision. Don't particularly
want to use runit for init and boot as that would require a lot of work.
this is not related to LXC, this behaviour is the same outside of a
container: you have to use the Slackware standard way to add
additional services at startup and shutdown.

for example, create an /etc/rc.d/rc.runit file with the following
content (dashes are just to delimit the blocks of text)

- - -
runit_start () {
/usr/bin/runsv /service
}

runit_stop () {
killall -9 runsv
}

case "$1" in
'start')
runit_start
;;
'stop')
runit_stop
;;
*)
echo "usage $0 start|stop"
esac
- - -

then add to /etc/rc.d/rc.local the following block

- - -
if [ -x /etc/rc.d/rc.runit ]; then
/etc/rc.d/rc.runit start
fi
- - -

and to /etc/rc.d/rc.local_shutdown the following

- - -
if [ -x /etc/rc.d/rc.runit ]; then
/etc/rc.d/rc.runit stop
fi
- - -

Matteo
spaceman
2018-09-18 11:29:43 UTC
Permalink
Hi,
Post by Matteo Bernardini
this is not related to LXC, this behaviour is the same outside of a
container: you have to use the Slackware standard way to add
additional services at startup and shutdown.
runit_start () {
/usr/bin/runsv /service
}
Yes that works, but try this instead:

runit_start () {
/usr/bin/runsv /service &
}

allowing both rc.runit and rc.local to finish (unless you want bash
running continously), however runsv just exits without a trace. This
works with several other of my rc scripts.

In bash '&' normally means background the process, but here the process
just disappears (with no output or exit code).

Using your script none of the rest of rc.local after you start rc.runit
will be executed until rc.runit stops.

Regards,
spaceman
Matteo Bernardini
2018-09-18 18:54:03 UTC
Permalink
Il giorno mar 18 set 2018 alle ore 13:30 spaceman
Post by Matteo Bernardini
Hi,
Post by Matteo Bernardini
this is not related to LXC, this behaviour is the same outside of a
container: you have to use the Slackware standard way to add
additional services at startup and shutdown.
runit_start () {
/usr/bin/runsv /service
}
runit_start () {
/usr/bin/runsv /service &
}
allowing both rc.runit and rc.local to finish (unless you want bash
running continously), however runsv just exits without a trace. This
works with several other of my rc scripts.
In bash '&' normally means background the process, but here the process
just disappears (with no output or exit code).
Using your script none of the rest of rc.local after you start rc.runit
will be executed until rc.runit stops.
that happens because, from what I have read on the matter (I am a
first timer with it), runit wants to stay in foreground: I had
provided general instructions for daemons in my first reply but this
doesn't seem to apply cleanly to runsv.

according to the official documentation

http://smarden.org/runit/useinit.html

your best option, as Slackware uses an hybrid init system (bsd +
sysinit), seems to be adding to /etc/inittab the line

SV:123456:respawn:/sbin/runsvdir-start

with a /service main directory containing other subdirectories for the
various services.

I don't know how you installed runit but /sbin/runsvdir-start is
provided in the package generated from the SlackBuild available at
slackbuilds.org

https://slackbuilds.org/repository/14.2/system/runit/

Matteo

Loading...