Skip to content

Prevent Cloud Run cold start thanks to sigterm management and self call

License

Notifications You must be signed in to change notification settings

guillaumeblaquiere/cloudrun-sigterm-selfcall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This repository demonstrates how to manage the graceful termination with Cloud Run in Go and how to call the service to always keep one instance warm and thus to minimize the cold starts.

This code illustrates this article

Deployment

Build

To build the container, you have several solution

Cloud Build with Buildpack (Dockerfile is useless, you can delete it in this case)

# Update with your project ID
PROJECT_ID=<MY_PROKECT_ID>

cloud builds submit --pack image=gcr.io/${PROJECT_ID}/self-call-sigterm

Cloud Build with Dockerfile

# Update with your project ID
PROJECT_ID=<MY_PROKECT_ID>

gcloud builds submit -t gcr.io/${PROJECT_ID}/self-call-sigterm

Locally with docker

# Update with your project ID
PROJECT_ID=<MY_PROKECT_ID>

docker build -t gcr.io/${PROJECT_ID}/self-call-sigterm .
docker push gcr.io/${PROJECT_ID}/self-call-sigterm

Deployment

Simply deploy the service on Cloud Run

# Update with your project ID
PROJECT_ID=<MY_PROKECT_ID>

gcloud run deploy --platform=managed --region=us-central1 --image=gcr.io/${PROJECT_ID}/self-call-sigterm \
--allow-unauthenticated self-call-sigterm

And then call it to initialize.

curl $(gcloud run services describe --format="value(status.url)" self-call-sigterm)

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

About

Prevent Cloud Run cold start thanks to sigterm management and self call

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published