Skip to content

Commit

Permalink
run systemctl as the init process
Browse files Browse the repository at this point in the history
  • Loading branch information
gdraheim committed Mar 21, 2017
1 parent d158665 commit 3515f94
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 53 deletions.
48 changes: 48 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
If this 'systemctl' is run without arguments
then it will default to "list-units".

## systemctl as init process

However... if systemctl is PID 1 then it will
run "1" which does both "default" and "wait".
So it will start all services in the default
target of "multi-user.target", it will then
wait for any child to be reaped. And when a
SIGTERM (aka "docker stop") is received then
it will stop all services in the default
target of "multi-user.target".

As recommendations, you may try to run

docker run --name running image /usr/bin/systemctl

and later

docker stop --time 100 running

Note that run does have a "--stop-timeout 100" in
later versions corresponding to docker-compse
stop_grace_period setting. In most cases the default
of 10 seconds is to short to bring down all services
correctly. Make it atleast 100 if you know that this
systemctl replacement is run as PID 1 .. i.e. as a
"init" process replacement.

You may force the docker-systemctl-replacement to
run as the init replacement simply by saying

/usr/bin/systemctl 1

which is identical to

/usr/bin/systemctl default
/usr/bin/systemctl wait

The handling of SIGTERM in "wait" is to call "halt"
which may also be issued manually to bring down
all services:

/usr/bin/systemctl halt

The systemctl commands "default" and "halt" are matching
those from the original, while "wait" is an innovation.
Loading

0 comments on commit 3515f94

Please # to comment.