Skip to content

Commit 6a13486

Browse files
committed
Set up health checks for microservices correctly
1 parent 4c5bf20 commit 6a13486

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

book-service/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ tasks.withType<ProcessAot> {
5454

5555
tasks.withType<BootBuildImage> {
5656
buildpacks = setOf("gcr.io/paketo-buildpacks/java-native-image", "gcr.io/paketo-buildpacks/health-checker")
57-
environment = mapOf(
58-
"BP_HEALTH_CHECKER_ENABLED" to "true",
59-
"THC_PATH" to "/actuator/health"
60-
)
57+
environment = mapOf("BP_HEALTH_CHECKER_ENABLED" to "true")
6158
imageName = "$dockerRepository:${project.name}"
6259
}
6360

compose.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ services:
88
restart: always
99
depends_on:
1010
- book-db
11+
environment:
12+
THC_PATH: "/actuator/health"
1113
healthcheck:
12-
test: [ "CMD", "health-check" ]
14+
test: [ "CMD", "/workspace/health-check" ]
1315
interval: 1m
1416
retries: 3
1517
start_period: 10s
@@ -21,8 +23,10 @@ services:
2123
restart: always
2224
depends_on:
2325
- user-db
26+
environment:
27+
THC_PATH: "/actuator/health"
2428
healthcheck:
25-
test: [ "CMD", "health-check" ]
29+
test: [ "CMD", "/workspace/health-check" ]
2630
interval: 1m
2731
retries: 3
2832
start_period: 10s
@@ -36,8 +40,9 @@ services:
3640
- user-db
3741
environment:
3842
SPRING_APPLICATION_NAME: user-service-2
43+
THC_PATH: "/actuator/health"
3944
healthcheck:
40-
test: [ "CMD", "health-check" ]
45+
test: [ "CMD", "/workspace/health-check" ]
4146
interval: 1m
4247
retries: 3
4348
start_period: 10s
@@ -49,8 +54,10 @@ services:
4954
restart: always
5055
depends_on:
5156
- notification-db
57+
environment:
58+
THC_PATH: "/actuator/health"
5259
healthcheck:
53-
test: [ "CMD", "health-check" ]
60+
test: [ "CMD", "/workspace/health-check" ]
5461
interval: 1m
5562
retries: 3
5663
start_period: 10s

notification-service/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ tasks.withType<ProcessAot> {
5656

5757
tasks.withType<BootBuildImage> {
5858
buildpacks = setOf("gcr.io/paketo-buildpacks/java-native-image", "gcr.io/paketo-buildpacks/health-checker")
59-
environment = mapOf(
60-
"BP_HEALTH_CHECKER_ENABLED" to "true",
61-
"THC_PATH" to "/actuator/health"
62-
)
59+
environment = mapOf("BP_HEALTH_CHECKER_ENABLED" to "true")
6360
imageName = "$dockerRepository:${project.name}"
6461
}
6562

user-service/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ kotlin {
4343

4444
tasks.withType<BootBuildImage> {
4545
buildpacks = setOf("gcr.io/paketo-buildpacks/java-native-image", "gcr.io/paketo-buildpacks/health-checker")
46-
environment = mapOf(
47-
"BP_HEALTH_CHECKER_ENABLED" to "true",
48-
"THC_PATH" to "/actuator/health"
49-
)
46+
environment = mapOf("BP_HEALTH_CHECKER_ENABLED" to "true")
5047
imageName = "$dockerRepository:${project.name}"
5148
}
5249

0 commit comments

Comments
 (0)