From 71dfbf9d9bfa776ad6e2085e4f6e827e42dd6d8a Mon Sep 17 00:00:00 2001 From: Mike Leone Date: Thu, 22 Jan 2015 10:22:40 -0500 Subject: [PATCH] Fixing stale pidfile issue when docker dies abruptly Signed-off-by: Mike Leone fixing indent Signed-off-by: Mike Leone Upstream-commit: 05d04843e6b80f131c07882c882f7e4da018a306 Component: engine --- components/engine/contrib/init/sysvinit-redhat/docker | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/engine/contrib/init/sysvinit-redhat/docker b/components/engine/contrib/init/sysvinit-redhat/docker index 1994d6b31e..d51e2f8ba1 100755 --- a/components/engine/contrib/init/sysvinit-redhat/docker +++ b/components/engine/contrib/init/sysvinit-redhat/docker @@ -43,6 +43,8 @@ prestart() { start() { [ -x $exec ] || exit 5 + check_for_cleanup + if ! [ -f $pidfile ]; then prestart printf "Starting $prog:\t" @@ -97,6 +99,13 @@ rh_status_q() { rh_status >/dev/null 2>&1 } + +check_for_cleanup() { + if [ -f ${pidfile} ]; then + /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile} + fi +} + case "$1" in start) rh_status_q && exit 0