diff --git a/Dockerfile b/Dockerfile index 8a28077..8afc497 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,7 +84,7 @@ RUN make install # Install start scripts COPY full_listing_cache_update.sh /full_listing_cache_update.sh COPY github_auth_cache_cleaner.sh /github_auth_cache_cleaner.sh -COPY start.sh /start.sh +COPY start.sh stop.sh / # Install HTML browse includes COPY include/browse_header.html /etc/nginx/browse_header.html diff --git a/charts/artifacts/templates/deployment.yaml b/charts/artifacts/templates/deployment.yaml index 34a271b..e6c84db 100644 --- a/charts/artifacts/templates/deployment.yaml +++ b/charts/artifacts/templates/deployment.yaml @@ -60,7 +60,7 @@ spec: lifecycle: preStop: exec: - command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"] + command: ["/stop.sh"] volumes: - name: cache emptyDir: {} diff --git a/stop.sh b/stop.sh new file mode 100755 index 0000000..2edb13a --- /dev/null +++ b/stop.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +echo "Stopping nginx..." +# Wait a bit before signaling the process to stop +sleep 5 +PID=$(cat /run/nginx.pid) +nginx -s quit + +echo "Waiting for nginx PID: ${PID} to stop..." +while [ -d /proc/$PID ]; do + sleep 0.1 +done