Search code examples
google-cloud-platformload-balancinggoogle-cloud-run

Is there any logs for cloud run container from idle to shutting/stopped?


As official GCP blog picture below

I want to know if any of my CloudRun load balance containers

From idle to shutting/stopped because there are no api requests

Is there any record on GCP?

Lifecycle of a container on Cloud Run


Solution

  • As suggested in this Documentation, you can build your application to handle a SIGTERM signal.

    Before shutting down an instance, Cloud Run sends a SIGTERM signal to all the containers in an instance, indicating the start of a 10 second period before the actual shutdown occurs, at which point Cloud Run sends a SIGKILL signal.

    Check with this documentation on how to handle SIGTERMs on Cloud Run so that your shutdowns will be graceful rather than abrupt.

    To check the logs, see this section in the Documentation,

    The scale-to-zero will trigger a SIGTERM signal to be sent to your container before it is shut down, and you can see the graceful shutdown routine executed in the Logs tab

    Also have a look at this Documentation and SF link.