2015-07-25 16:43 GMT-03:00 Guillermo:
> Since version 0.16, OpenRC can launch supervised daemons using
> s6, as an alternative to (its implementation of) start-stop-daemon(8).

And for release 0.21, the authors have also rolled their own
experimental process supervision tool: the supervise-daemon(8)


Service scripts can specify that daemons they launch should be
supervised by it by including a 'supervisor=supervise-daemon'
assignment. No start() and stop() functions are allowed in this case,
and the daemon and its command line arguments have to be specified by
assignments to 'command' and 'command_args', just like when using
start-stop-daemon(8). Specifying a PID file (by assignment to
'pidfile') is mandatory, probably so that the openrc and rc-service
programs know which supervise-daemon process to kill when the
corresponding service is wanted down. Yeah, I can hear the screams
:-D, but I guess OpenRC can't do it any other way without a major
redesign. Anyway, I thought it still deserved a mention :)

Process supervision with s6 (specified in service scripts with a
'supervisor=s6' assignment and a 'need s6-svscan' dependency)
continues to be supported. In fact, for release 0.21 they have also
fixed the s6-svc invocations in OpenRC's code, so this feature should
now work with s6- and later.

Short demonstration
$ cat /home/test-user/useless-daemon

#!/bin/execlineb -S1
s6-setuidgid test-user
foreground { fdmove -c 1 2 echo useless-daemon (re)started }
sleep $1

$ cat /home/test-user/useless-daemon-log

# Because, why not? xD
fifo-listen --uid 1000 /home/test-user/useless-daemon-fifo
setuidgid test-user
fdmove --copy 0 3
cyclog /home/test-user/useless-daemon-logdir

$ cat /etc/init.d/useless-daemon-supervised

supervise_daemon_args="--stderr /home/test-user/useless-daemon-fifo"

depend() {
   need useless-daemon-logger

$ cat /etc/init.d/useless-daemon-logger


$ cat /etc/conf.d/useless-daemon-supervised


$ sudo rc-service useless-daemon-supervised start

 * Starting useless-daemon-logger ...     [ ok ]
 * Starting useless-daemon-supervised ... [ ok ]

$ rc-status

Dynamic Runlevel: needed/wanted
 useless-daemon-logger                                             [  started  ]
Dynamic Runlevel: manual
 useless-daemon-supervised                                         [  started  ]

$ ps -eo pid,ppid,args | grep $(cat /home/test-user/useless-daemon-log.pid)

 2802     1 supervise-daemon --start --pidfile
/home/test-user/useless-daemon-log --
 2875  2802 cyclog /home/test-user/useless-daemon-logdir

$ ps -eo pid,ppid,args | grep $(cat /home/test-user/useless-daemon.pid)

 2824     1 supervise-daemon --start --pidfile
/home/test-user/useless-daemon.pid --stderr
/home/test-user/useless-daemon-pipe /home/test-user/useless-daemon --
 2884  2824 sleep 10

(Yeah, not a supervision *tree*, but...)

$ sudo rc-service useless-daemon-supervised stop

 * Stopping useless-daemon-supervised ... [ ok ]

$ sudo rc-service useless-daemon-logger stop

 * Stopping useless-daemon-logger ...     [ ok ]

$ tai64nlocal /home/test-user/useless-daemon-logdir/current

2016-06-18 16:32:08.419976087 useless-daemon (re)started
2016-06-18 16:32:18.670540023 useless-daemon (re)started
2016-06-18 16:32:28.893868416 useless-daemon (re)started
2016-06-18 16:32:39.102626965 useless-daemon (re)started
2016-06-18 16:32:49.304317136 useless-daemon (re)started

Reply via email to