Use nginx restart instead of reload for blue-green switch (#5260)

nginx reload doesn't always force DNS re-resolution in Docker. During
blue-green deployment, after updating nginx.conf to point to the new
instance (e.g., eagle-green:40032), nginx -s reload would sometimes
keep trying to connect to the old (now removed) container, causing
502 errors.

A full restart ensures nginx picks up the new upstream correctly.
The ~1-2 second restart time is acceptable for deployment reliability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-12 19:52:56 -08:00
committed by GitHub
co-authored by Claude Opus 4.5
parent 0e3f1bcb87
commit d0d84e98e0
+7 -7
View File
@@ -221,7 +221,7 @@ main() {
echo "JFR_SIDECAR_ADDR=jfr-sidecar:8081" >> "${env_file}"
fi
# Validate nginx config before reload
# Validate nginx config before restart
log_info "Validating nginx configuration..."
if ! docker exec nginx nginx -t 2>&1; then
log_error "nginx config validation failed, aborting!"
@@ -230,12 +230,12 @@ main() {
exit 1
fi
# Reload nginx (use reload for faster switch, restart if reload fails)
log_info "Reloading nginx..."
if ! docker exec nginx nginx -s reload 2>/dev/null; then
log_warn "Reload failed, restarting nginx..."
docker compose -f "${COMPOSE_FILE}" restart nginx
fi
# Restart nginx to pick up new upstream
# Note: We use restart instead of reload because reload doesn't always
# force DNS re-resolution in Docker, causing nginx to keep trying to
# connect to the old (removed) container
log_info "Restarting nginx..."
docker compose -f "${COMPOSE_FILE}" restart nginx
# Restart admin to pick up new .env
log_info "Restarting admin service..."