X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=image%2Fbase%2Fboot;h=3e46a06a15d312227d34b7d8205e9847911215e7;hb=c29734058ba46a87ebb532550911c56f2d14b8f9;hp=38b5294f73a47f77375eb226a626fd0df026ab81;hpb=074f2b6aec69235097c214fb3a2a43e285a7eb22;p=discourse_docker.git diff --git a/image/base/boot b/image/base/boot index 38b5294..3e46a06 100755 --- a/image/base/boot +++ b/image/base/boot @@ -2,9 +2,26 @@ # we use this to boot up cause runit will not handle TERM and will not exit when done +shutdown() { + echo Shutting Down + /etc/runit/3 + ls /etc/service | SHELL=/bin/sh parallel sv force-stop {} + kill -HUP $RUNSVDIR + wait $RUNSVDIR + + # give stuff a bit of time to finish + sleep 0.1 + + ORPHANS=`ps -eo pid | grep -v PID | tr -d ' ' | grep -v '^1$'` + SHELL=/bin/bash parallel 'timeout 5 /bin/bash -c "kill {} && wait {}" || kill -9 {}' ::: $ORPHANS 2> /dev/null + exit +} + /etc/runit/1 /etc/runit/2& RUNSVDIR=$! echo "Started runsvdir, PID is $RUNSVDIR" -trap "echo Shutting Down && /etc/runit/3 && kill -HUP $RUNSVDIR && wait $RUNSVDIR" SIGTERM SIGHUP +trap shutdown SIGTERM SIGHUP wait $RUNSVDIR + +shutdown