Skip to content

Commit

Permalink
Improve gracefull shutdown of artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmet committed Feb 1, 2024
1 parent c535355 commit 7e045e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/artifacts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
14 changes: 14 additions & 0 deletions stop.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7e045e1

Please sign in to comment.