Files
2026-07-05 14:43:34 +08:00

40 lines
1.2 KiB
Bash

#!/bin/bash
echo "--- before ---"
ps -efL | grep "nginx" | grep -v grep | head -5
# Find s6-supervise for nginx
S6_PID=$(ps -efL | grep "s6-supervise nginx" | grep -v grep | awk '{print $2}' | head -1)
echo "S6 supervisor PID: $S6_PID"
# Send SIGTERM/QUIT to nginx master - s6 will restart it
NGINX_MASTER=$(ps -efL | grep "nginx: master" | grep -v grep | awk '{print $2}' | head -1)
echo "Killing nginx master $NGINX_MASTER with SIGQUIT (graceful)"
# Try SIGQUIT first (graceful shutdown)
kill -QUIT "$NGINX_MASTER" 2>&1
sleep 3
# If still running, force kill
if kill -0 "$NGINX_MASTER" 2>/dev/null; then
echo "Still running, sending SIGTERM"
kill -TERM "$NGINX_MASTER"
sleep 2
fi
if kill -0 "$NGINX_MASTER" 2>/dev/null; then
echo "Still running, sending SIGKILL"
kill -KILL "$NGINX_MASTER"
sleep 2
fi
# Wait for s6 to restart
sleep 5
echo "--- after ---"
ps -efL | grep "nginx" | grep -v grep | head -5
# Test
echo "--- TEST 80 ---"
curl -o /dev/null -s -w "HTTP %{http_code} size=%{size_download} type=%{content_type}\n" http://localhost/uploads/1781403331659-1cac3cac.png
echo "--- TEST 80 API ---"
curl -o /dev/null -s -w "HTTP %{http_code}\n" http://localhost/api/v1/banners