diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4c30839ed574fcfdd59f795471a3306503f56f69..5670f8aa60d135eb697634b7e85c3732c497c44b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,7 +49,7 @@ variables: ## common steps cache_lint_test: - image: 'europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/denoland/deno:2.1.9' + image: 'europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/denoland/deno:2.1.10' stage: 'test' script: - deno cache --allow-import --lock=deno.lock app/deps.ts app/dev_deps.ts diff --git a/Dockerfile b/Dockerfile index 6f5a9cee2a3247a2eebd8d9de3ee40c8a368fb5a..362cefdb9e22540f49e7113b2a30926ba4643391 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/denoland/deno:2.1.9 +FROM europe-north1-docker.pkg.dev/holi-shared/docker-hub-remote/denoland/deno:2.1.10 # The port that your application listens to. EXPOSE 8003 diff --git a/app/server.ts b/app/server.ts index 8a50b2a16ea10c6519c1acf65c2fa222e7373b2f..f8ba4e369d4567cedcd4052a1f988ddb265d3a77 100644 --- a/app/server.ts +++ b/app/server.ts @@ -141,7 +141,18 @@ export type GraphQLServer = any export const startServer = (config: ServerConfig): Promise<void> => { const graphQLServer: GraphQLServer = createGraphQLServer(config) - return serve(graphQLServer.handleRequest, { + + const handler = (request: Request): Response => { + const url = new URL(request.url) + + if (url.pathname === '/health') { + return new Response('OK', { status: 200 }) + } + + return graphQLServer.handleRequest(request) + } + + return serve(handler, { port: config.port, onListen({ port, hostname }) { logger.info( diff --git a/terraform/environments/deployment.tf b/terraform/environments/deployment.tf index 34f9b14c3baf6d27d0c53d8266e2d163a576755f..1ec8a43a6d6c6022b37809eb98d435456918edbb 100644 --- a/terraform/environments/deployment.tf +++ b/terraform/environments/deployment.tf @@ -70,6 +70,24 @@ resource "google_cloud_run_service" "geo_api" { memory = local.environment == "production" ? "512Mi" : "256Mi" } } + startup_probe { + http_get { + path = "/health" + } + initial_delay_seconds = 5 + failure_threshold = 3 + period_seconds = 5 + timeout_seconds = 2 + } + liveness_probe { + http_get { + path = "/health" + } + initial_delay_seconds = 10 + period_seconds = 30 + timeout_seconds = 2 + failure_threshold = 3 + } } container_concurrency = 0 # 0 means thread safe, no restriction on max concurrency } @@ -82,7 +100,7 @@ resource "google_cloud_run_service" "geo_api" { "run.googleapis.com/vpc-access-connector" = data.terraform_remote_state.holi_infra_state.outputs.vpc_access_connector_name # possible values: all-traffic/private-ranges-only(default) https://cloud.google.com/sdk/gcloud/reference/run/services/update#--vpc-egress "run.googleapis.com/vpc-access-egress" = "private-ranges-only" - "run.googleapis.com/startup-cpu-boost" = "true" + "run.googleapis.com/startup-cpu-boost" = "true" } # labels set on the revision level labels = {