From 102de840cc19b3a116da079f3bd03821bb6ee0b8 Mon Sep 17 00:00:00 2001 From: Robert Kenny Date: Sun, 14 Jan 2024 14:58:59 +0000 Subject: [PATCH 1/3] Adds a simple healthcheck endpoint for the items service This change follows https://github.com/wellcomecollection/catalogue-api/pull/736, and adds an HTTP healthcheck to the items API to ensure the scala service has started before it is registered healthy at the NLB and starts serving requests. --- items/src/main/scala/weco/api/items/ItemsApi.scala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/items/src/main/scala/weco/api/items/ItemsApi.scala b/items/src/main/scala/weco/api/items/ItemsApi.scala index d14df2f267..4ffd946f6d 100644 --- a/items/src/main/scala/weco/api/items/ItemsApi.scala +++ b/items/src/main/scala/weco/api/items/ItemsApi.scala @@ -36,6 +36,14 @@ class ItemsApi( case id => notFound(s"Work not found for identifier $id") } + }, + pathPrefix("management") { + concat( + path("healthcheck") { + get { + complete("message" -> "ok") + } + }) } ) } From 3f7c0cb0b0e38891487573536f3d58bc72284b9f Mon Sep 17 00:00:00 2001 From: Robert Kenny Date: Thu, 25 Jan 2024 13:46:01 +0000 Subject: [PATCH 2/3] enable the http healthcheck for items api --- terraform/modules/stack/services.tf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/terraform/modules/stack/services.tf b/terraform/modules/stack/services.tf index 384f1f378b..66c104e56e 100644 --- a/terraform/modules/stack/services.tf +++ b/terraform/modules/stack/services.tf @@ -93,6 +93,9 @@ module "items_api" { vpc_id = var.vpc_id load_balancer_arn = aws_lb.catalogue_api.arn + # Use the HTTP healthcheck with a default path of /management/healthcheck + tcp_healthcheck = false + use_fargate_spot = var.environment_name == "stage" ? true : false turn_off_outside_office_hours = var.environment_name == "stage" ? true : false } From 1da4ee6bd2c45b6fcfc500f26477e5df95fe4b0a Mon Sep 17 00:00:00 2001 From: Buildkite on behalf of Wellcome Collection Date: Thu, 25 Jan 2024 13:47:12 +0000 Subject: [PATCH 3/3] Apply auto-formatting rules --- items/src/main/scala/weco/api/items/ItemsApi.scala | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/items/src/main/scala/weco/api/items/ItemsApi.scala b/items/src/main/scala/weco/api/items/ItemsApi.scala index 4ffd946f6d..00ed3e59c6 100644 --- a/items/src/main/scala/weco/api/items/ItemsApi.scala +++ b/items/src/main/scala/weco/api/items/ItemsApi.scala @@ -38,12 +38,11 @@ class ItemsApi( } }, pathPrefix("management") { - concat( - path("healthcheck") { - get { - complete("message" -> "ok") - } - }) + concat(path("healthcheck") { + get { + complete("message" -> "ok") + } + }) } ) }