fix: use exec form CMD so uvicorn receives SIGTERM as PID 1

Shell form CMD makes /bin/sh PID 1 — SIGTERM from docker stop goes to
the shell, not uvicorn, causing SIGKILL after the stop timeout instead
of graceful shutdown. Using CMD ["sh", "-c", "exec uvicorn ..."] lets
the shell expand $WEB_WORKERS then exec-replaces itself with uvicorn,
restoring correct signal delivery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-04-09 09:01:18 -05:00
parent 0095d2a792
commit 6efba473a0

View File

@ -31,4 +31,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
# Start uvicorn
ENV WEB_WORKERS=2
CMD uvicorn app.main:app --host 0.0.0.0 --port 80 --workers $WEB_WORKERS
CMD ["sh", "-c", "exec uvicorn app.main:app --host 0.0.0.0 --port 80 --workers $WEB_WORKERS"]