The container doesn't listen to SIGTERM, meaning Docker [stop / restart] has to kill it forcefully after waiting 10 seconds (default timeout).
This can either be fixed by prepending the command with 'exec':
CMD exec gunicorn main:app --max-requests 3000 --max-requests-jitter 150 --workers $WORKERS --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT
Or using exec form (which doesn't work because of the environent variables, you'd have to set the entrypoint to a small .sh script that does the same):
CMD ["gunicorn", "main:app", ...]
Good catch! I added exec to the CMD as you proposed. The change has been deployed in version v1.13.5. I tested the change on my own Kubernetes test cluster and it seems to have the intended effect.
The container doesn't listen to SIGTERM, meaning Docker [stop / restart] has to kill it forcefully after waiting 10 seconds (default timeout).
This can either be fixed by prepending the command with 'exec':
CMD exec gunicorn main:app --max-requests 3000 --max-requests-jitter 150 --workers $WORKERS --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT
Or using exec form (which doesn't work because of the environent variables, you'd have to set the entrypoint to a small .sh script that does the same):
CMD ["gunicorn", "main:app", ...]
See https://lucaspin.medium.com/where-is-my-sigterm-docker-ff7fd8aec757 for more info.