From c93a14391a4886b3a1009aa081b0e8f625c2a923 Mon Sep 17 00:00:00 2001 From: "Hongli Lai (Phusion)" Date: Fri, 8 Jul 2016 18:37:03 +0200 Subject: [PATCH] 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. --- Changelog.md | 2 ++ image/bin/my_init | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index f3fea27..447cca8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,8 @@ ## 0.9.19 (not yet released) * Upgraded to Ubuntu 16.04. Thanks to Pierre Jacomet for submitting this patch. + * During shutdown, repeatedly tell Runit to shutdown services in order to workaround a potential race condition in Runit itself. Closes GH-315. Thanks to Chris Kite for submitting this patch. + ## 0.9.18 (release date: 2015-12-08) diff --git a/image/bin/my_init b/image/bin/my_init index a023b2a..bcdbc05 100755 --- a/image/bin/my_init +++ b/image/bin/my_init @@ -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")