Skip to content

Commit c9938e1

Browse files
committed
Optimize Docker container shutdown speed
- Add signal handling to entrypoint.sh for faster container shutdown - Use 'nginx -s stop' for immediate termination instead of graceful shutdown - Trap SIGTERM/SIGINT signals to respond quickly to Docker stop commands
1 parent ef8030d commit c9938e1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,15 @@
33
envsubst '${SEARCH_HIGHLIGHT_LIMIT} ${SEARCH_TERM_MIN_LENGTH}' < /usr/share/nginx/html/index.html > /usr/share/nginx/html/index.html.tmp
44
mv /usr/share/nginx/html/index.html.tmp /usr/share/nginx/html/index.html
55

6+
# Function to handle shutdown signals
7+
shutdown() {
8+
echo "Shutting down nginx..."
9+
nginx -s stop
10+
exit 0
11+
}
12+
13+
# Trap SIGTERM and SIGINT for graceful shutdown
14+
trap shutdown SIGTERM SIGINT
15+
616
# Start nginx
717
nginx -g 'daemon off;'

0 commit comments

Comments
 (0)