From d8f46969c4a01819ee6217c1ab525a7dec955647 Mon Sep 17 00:00:00 2001 From: Valentin Aitken Date: Thu, 26 Jul 2018 14:48:15 +0300 Subject: [PATCH] Do not fork a process for a condition check Fork process only when AUTORELOAD is true. Not needed to fork a process even when AUTORELOAD is false. --- docker/entrypoint.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index c138f58..1b754e9 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -17,8 +17,9 @@ echoerr() { printf "%(%FT%TZ)T %s\n" -1 "$*" >&2; } nginx -t -g 'daemon off;' || ( echoerr "Nginx configuration test failed" && exit 1 ) #Run nginx graceful autoreload check in background -[[ $AUTORELOAD ]] && ( - sleep 1 +if [[ $AUTORELOAD ]] +then +(sleep 1 [[ "$AUTORELOAD_CHECK_METHOD" = "timestamp" ]] && CHECK_METHOD='timestamp' || CHECK_METHOD='checksum' echoerr "Autoreload: Waiting for ${AUTORELOAD_CHECK_FILE:=/etc/nginx/nginx.conf} changes to autoreload nginx." \ @@ -44,6 +45,7 @@ nginx -t -g 'daemon off;' || ( echoerr "Nginx configuration test failed" && exit nginx -t && nginx -s reload fi done -) & + ) & +fi exec nginx -g 'daemon off;'