From 452e60024b8e87b90b3a17cf003ded884a95ea03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Cie=C5=9Bnik?= Date: Wed, 29 Jan 2020 23:14:49 +0100 Subject: [PATCH 1/2] Stop container if nginx stops --- src/scripts/entrypoint.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/scripts/entrypoint.sh b/src/scripts/entrypoint.sh index abeb2c1..419442c 100644 --- a/src/scripts/entrypoint.sh +++ b/src/scripts/entrypoint.sh @@ -35,6 +35,13 @@ while [ true ]; do sleep 604810 & SLEEP_PID=$! - # Wait on sleep so that when we get ctrl-c'ed it kills everything due to our trap - wait "$SLEEP_PID" + # Wait for 1 week sleep or nginx + wait -n $SLEEP_PID $NGINX_PID + + # Make sure we do not run container empty (without nginx process). + # If nginx quit for whatever reason then stop the container. + # Leave the restart decision to the container orchestration. + if ! jobs | grep --quiet nginx ; then + exit 1 + fi done From d89eae28799c28b947c5985f3eb9a9bd4358f650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Cie=C5=9Bnik?= Date: Sun, 2 Feb 2020 17:57:26 +0100 Subject: [PATCH 2/2] indentation fix --- src/scripts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/entrypoint.sh b/src/scripts/entrypoint.sh index 419442c..64f3759 100644 --- a/src/scripts/entrypoint.sh +++ b/src/scripts/entrypoint.sh @@ -42,6 +42,6 @@ while [ true ]; do # If nginx quit for whatever reason then stop the container. # Leave the restart decision to the container orchestration. if ! jobs | grep --quiet nginx ; then - exit 1 + exit 1 fi done