During shutdown, repeatedly tell Runit to shutdown services

Works around a potential race condition in Runit itself.
Closes GH-315. Thanks to Chris Kite for submitting this patch.
This commit is contained in:
Hongli Lai (Phusion)
2016-07-08 18:37:03 +02:00
parent 1f39ac326f
commit c93a14391a
2 changed files with 11 additions and 2 deletions

View File

@@ -244,8 +244,9 @@ def wait_for_runit_or_interrupt(pid):
except KeyboardInterrupt:
return (False, None)
def shutdown_runit_services():
debug("Begin shutting down runit services...")
def shutdown_runit_services(quiet = False):
if not quiet:
debug("Begin shutting down runit services...")
os.system("/usr/bin/sv down /etc/service/*")
def wait_for_runit_services():
@@ -255,6 +256,12 @@ def wait_for_runit_services():
done = os.system("/usr/bin/sv status /etc/service/* | grep -q '^run:'") != 0
if not done:
time.sleep(0.1)
# According to https://github.com/phusion/baseimage-docker/issues/315
# there is a bug or race condition in Runit, causing it
# not to shutdown services that are already being started.
# So during shutdown we repeatedly instruct Runit to shutdown
# services.
shutdown_runit_services(true)
def install_insecure_key():
info("Installing insecure SSH key for user root")