Gracefully handle container instance termination
Problem to solve
Cloud Run can shut down a container instance at any time. Right now, we lack structured logging around when a container instance was shut down, either expectedly from autoscaling/deployment, or unexpectedly from GCP.
Proposal
Update uvicorn
server to handle signal.SIGINT
sent from Cloud Run, eg: https://cloud.google.com/run/docs/samples/cloudrun-sigterm-handler#cloudrun_sigterm_handler-python.
Further details
Links / references
Edited by Chance Feick