b4b2c78530 | ||
---|---|---|
example | ||
zombietest | ||
.gitignore | ||
LICENSE | ||
README.md | ||
circle.yml | ||
main.go |
README.md
runsvinit
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.