diff options
author | Konstantin Pavlov <thresh@nginx.com> | 2022-12-13 13:36:39 -0800 |
---|---|---|
committer | Konstantin Pavlov <thresh@nginx.com> | 2022-12-13 13:36:39 -0800 |
commit | 63cc4a31bdea2601c8adc08194759657f1476b16 (patch) | |
tree | 586ba662caaf9def9673f5b595f4deedcea91c14 | |
parent | f09d0e22847b2d2dab79f782c55067c596e38fb1 (diff) | |
download | unit-63cc4a31bdea2601c8adc08194759657f1476b16.tar.gz unit-63cc4a31bdea2601c8adc08194759657f1476b16.tar.bz2 |
Docker: limited the waiting time for control socket removal.
Fixes https://github.com/nginx/unit/issues/728
Refs https://github.com/nginx/unit/issues/718
Diffstat (limited to '')
-rwxr-xr-x | pkg/docker/docker-entrypoint.sh | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/pkg/docker/docker-entrypoint.sh b/pkg/docker/docker-entrypoint.sh index 7f65d94a..3d134ea2 100755 --- a/pkg/docker/docker-entrypoint.sh +++ b/pkg/docker/docker-entrypoint.sh @@ -2,6 +2,9 @@ set -e +WAITLOOPS=5 +SLEEPSEC=1 + curl_put() { RET=$(/usr/bin/curl -s -w '%{http_code}' -X PUT --data-binary @$1 --unix-socket /var/run/control.unit.sock http://localhost/$2) @@ -57,7 +60,18 @@ if [ "$1" = "unitd" ] || [ "$1" = "unitd-debug" ]; then echo "$0: Stopping Unit daemon after initial configuration..." kill -TERM $(/bin/cat /var/run/unit.pid) - while [ -S /var/run/control.unit.sock ]; do echo "$0: Waiting for control socket to be removed..."; /bin/sleep 0.1; done + for i in $(/usr/bin/seq $WAITLOOPS); do + if [ -S /var/run/control.unit.sock ]; then + echo "$0 Waiting for control socket to be removed..." + /bin/sleep $SLEEPSEC + else + break + fi + done + if [ -S /var/run/control.unit.sock ]; then + kill -KILL $(/bin/cat /var/run/unit.pid) + rm -f /var/run/control.unit.sock + fi echo echo "$0: Unit initial configuration complete; ready for start up..." |