-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
98 lines (93 loc) · 2.16 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from fastapi import FastAPI, status
from examples.probes import (
LIVENESS_CHECKS,
READINESS_CHECKS,
READINESS_CHECKS_FAIL,
READINESS_CHECKS_SUCCESS,
STARTUP_CHECKS,
custom_handler,
)
from fast_healthchecks.integrations.fastapi import HealthcheckRouter, Probe
app_integration = FastAPI()
app_integration.include_router(
HealthcheckRouter(
Probe(
name="liveness",
checks=LIVENESS_CHECKS,
),
Probe(
name="readiness",
checks=READINESS_CHECKS,
),
Probe(
name="startup",
checks=STARTUP_CHECKS,
),
debug=True,
prefix="/health",
),
)
app_success = FastAPI()
app_success.include_router(
HealthcheckRouter(
Probe(
name="liveness",
checks=[],
),
Probe(
name="readiness",
checks=READINESS_CHECKS_SUCCESS,
),
Probe(
name="startup",
checks=[],
),
debug=True,
prefix="/health",
),
)
app_fail = FastAPI()
app_fail.include_router(
HealthcheckRouter(
Probe(
name="liveness",
checks=[],
),
Probe(
name="readiness",
checks=READINESS_CHECKS_FAIL,
),
Probe(
name="startup",
checks=[],
),
debug=True,
prefix="/health",
),
)
app_custom = FastAPI()
app_custom.include_router(
HealthcheckRouter(
Probe(
name="liveness",
checks=[],
summary="Check if the application is alive",
),
Probe(
name="readiness",
checks=READINESS_CHECKS_SUCCESS,
summary="Check if the application is ready",
),
Probe(
name="startup",
checks=[],
summary="Check if the application is starting up",
),
success_handler=custom_handler,
failure_handler=custom_handler,
success_status=status.HTTP_200_OK,
failure_status=status.HTTP_503_SERVICE_UNAVAILABLE,
debug=True,
prefix="/custom_health",
),
)