-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhealthcheck_example.ctst
More file actions
65 lines (60 loc) · 1.73 KB
/
healthcheck_example.ctst
File metadata and controls
65 lines (60 loc) · 1.73 KB
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
// Health checks and restart policies.
//
// Healthchecks control CONNECT ordering — a dependency is not
// considered ready until its healthcheck passes. Combined with
// restart policies, they enable self-healing deployments.
COMPONENT api {
image = "file:///opt/images/myapp-api"
port = 8080
memory = "256MiB"
readonly = true
// Restart only on crash or when healthcheck reports unhealthy.
restart = "on-failure"
healthcheck = {
command = ["curl", "-f", "http://localhost:8080/healthz"]
interval = "10s"
timeout = "3s"
retries = 5
start_period = "20s"
}
env = {
DATABASE_URL = "postgres://${db.host}:${db.port}/app"
}
}
COMPONENT db {
image = "file:///opt/images/postgres-16"
port = 5432
memory = "512MiB"
volume = "/data/healthcheck-demo:/var/lib/postgresql/data"
readonly = false
// Critical data store — always restart regardless of exit code.
restart = "always"
healthcheck = {
command = ["pg_isready", "-U", "postgres"]
interval = "5s"
timeout = "2s"
retries = 10
}
env = {
POSTGRES_PASSWORD = "${secret.db_password}"
}
}
COMPONENT cache {
image = "tar:///opt/images/redis-7.tar"
port = 6379
memory = "128MiB"
readonly = true
// Redis restarts on failure; healthcheck verifies PING response.
restart = "on-failure"
healthcheck = {
command = ["redis-cli", "ping"]
interval = "5s"
timeout = "2s"
retries = 5
start_period = "5s"
}
command = ["redis-server", "--maxmemory", "100mb"]
}
CONNECT api -> db
CONNECT api -> cache
EXPOSE 8080