Go to file
Peter Bourgon b4b2c78530 circle.yml: RM becomes RMCONTAINER 2015-10-07 15:43:35 +02:00
example Review feedback 2015-10-07 15:39:45 +02:00
zombietest Review feedback 2015-10-07 15:39:45 +02:00
.gitignore Working test 2015-09-28 22:30:44 +02:00
LICENSE Initial commit 2015-09-25 11:29:49 +02:00
README.md Review feedback 2015-10-07 15:39:45 +02:00
circle.yml circle.yml: RM becomes RMCONTAINER 2015-10-07 15:43:35 +02:00
main.go Review feedback 2015-10-07 15:39:45 +02:00

README.md

runsvinit Circle CI

If you have a Docker container that's a collection of runit-supervised daemons, this process is suitable for use as the ENTRYPOINT. See the example.

Why not use runit(8) directly?

runit(8) is designed to be used as process 1. And, if you provide an /etc/service/ctrlaltdel script, it will be executed when runit receives the INT signal. So, we could use that hook to gracefully terminate our services. But Docker only sends TERM on docker stop.

Note that the container stop signal will become configurable in Docker 1.9. Once Docker 1.9 ships, this utility will be obsolete.

Why not just exec runsvdir(8) directly?

If runsvdir(8) receives a signal, it doesn't wait for its supervised processes to exit before returning.

Why not wrap runsvdir(8) in a simple shell script?

Process 1 has the additional responsibility of reaping orphaned child processes. To the best of my knowledge, there is no sane way to do this with a shell script. Otherwise, indeed, this would work great:

#!/bin/sh

sv_stop() {
	for s in $(ls -d /etc/service/*)
	do
		/sbin/sv stop $s
	done
}

trap "sv_stop; exit" SIGTERM
/sbin/runsvdir /etc/service &
wait

Why not use my_init from phusion/baseimage-docker?

my_init depends on Python 3, which might be a big dependency for such a small responsibility.

So this is just a stripped-down my_init in Go?

Basically, yes.