Skip to content

Commit 9a877e1

Browse files
committed
build(docker-compose): setup health check for each airflow component
1 parent 9022435 commit 9a877e1

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

docker-compose-dev.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ x-docker-common: &docker-common
88
- ./sqlite:/opt/airflow/sqlite
99
# you can comment out the following line if you don't have service-account.json
1010
- ./service-account.json:/opt/airflow/service-account.json
11+
environment:
12+
AIRFLOW__CORE__EXECUTION_API_SERVER_URL: 'http://airflow-api-server:8080/execution/'
1113
logging:
1214
driver: json-file
1315
options:
@@ -21,7 +23,7 @@ services:
2123
- "8080:8080"
2224
command: api-server
2325
healthcheck:
24-
test: ["CMD", "curl", "--fail", "http://localhost:8080/health"]
26+
test: ["CMD", "curl", "--fail", "http://localhost:8080/api/v2/version"]
2527
interval: 30s
2628
timeout: 10s
2729
retries: 5
@@ -35,6 +37,12 @@ services:
3537
<<: *docker-common
3638
container_name: airflow-dag-processor
3739
command: dag-processor
40+
healthcheck:
41+
test: ["CMD-SHELL", 'airflow jobs check --job-type DagProcessorJob --hostname "$${HOSTNAME}"']
42+
interval: 30s
43+
timeout: 10s
44+
retries: 5
45+
start_period: 30s
3846
restart: always
3947
depends_on:
4048
airflow-init:
@@ -44,6 +52,12 @@ services:
4452
<<: *docker-common
4553
container_name: airflow-scheduler
4654
command: scheduler
55+
healthcheck:
56+
test: ["CMD", "curl", "--fail", "http://localhost:8974/health"]
57+
interval: 30s
58+
timeout: 10s
59+
retries: 5
60+
start_period: 30s
4761
restart: always
4862
depends_on:
4963
airflow-init:
@@ -58,7 +72,6 @@ services:
5872
if [[ -n "$${_AIRFLOW_DB_MIGRATE=}" ]]; then
5973
airflow db migrate || true
6074
fi
61-
exit 0
6275
restart: "no"
6376
environment:
6477
_AIRFLOW_DB_MIGRATE: 'false'

docker-compose.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ services:
1818
- "8080:8080"
1919
command: api-server
2020
healthcheck:
21-
test: ["CMD", "curl", "--fail", "http://localhost:8080/health"]
21+
test: ["CMD", "curl", "--fail", "http://localhost:8080/api/v2/version"]
2222
interval: 30s
2323
timeout: 10s
2424
retries: 5
@@ -32,6 +32,12 @@ services:
3232
<<: *docker-common
3333
container_name: airflow-dag-processor
3434
command: dag-processor
35+
healthcheck:
36+
test: ["CMD-SHELL", 'airflow jobs check --job-type DagProcessorJob --hostname "$${HOSTNAME}"']
37+
interval: 30s
38+
timeout: 10s
39+
retries: 5
40+
start_period: 30s
3541
restart: always
3642
depends_on:
3743
airflow-init:
@@ -41,6 +47,12 @@ services:
4147
<<: *docker-common
4248
container_name: airflow-scheduler
4349
command: scheduler
50+
healthcheck:
51+
test: ["CMD", "curl", "--fail", "http://localhost:8974/health"]
52+
interval: 30s
53+
timeout: 10s
54+
retries: 5
55+
start_period: 30s
4456
restart: always
4557
depends_on:
4658
airflow-init:

0 commit comments

Comments
 (0)