Skip to content

Commit 93a6853

Browse files
committed
add immich-healthcheck
1 parent 5ce21fd commit 93a6853

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,17 @@ services:
7676
ports:
7777
- 8080:8080
7878
restart: unless-stopped
79-
79+
depends_on:
80+
postgres14:
81+
condition: service_healthy
82+
redis:
83+
condition: service_healthy
84+
healthcheck:
85+
test: immich-healthcheck
86+
start_period: 20s
87+
interval: 30s
88+
retries: 5
89+
timeout: 5s
8090
# This container requires an external application to be run separately.
8191
# By default, ports for the databases are opened, be careful when deploying it
8292
# Redis:
@@ -85,6 +95,13 @@ services:
8595
ports:
8696
- 6379:6379
8797
container_name: redis
98+
healthcheck:
99+
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
100+
start_period: 20s
101+
interval: 30s
102+
retries: 5
103+
timeout: 5s
104+
88105
# PostgreSQL 14:
89106
postgres14:
90107
image: tensorchord/pgvecto-rs:pg14-v0.2.0
@@ -97,7 +114,12 @@ services:
97114
POSTGRES_DB: immich
98115
volumes:
99116
- path_to_postgres:/var/lib/postgresql/data
100-
117+
healthcheck:
118+
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
119+
start_period: 20s
120+
interval: 30s
121+
retries: 5
122+
timeout: 5s
101123
```
102124
103125
### Docker CLI ([Click here for more info](https://docs.docker.com/engine/reference/commandline/cli/))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ ( $IMMICH_WORKERS_INCLUDE != '' && $IMMICH_WORKERS_INCLUDE != *api* ) || $IMMICH_WORKERS_EXCLUDE == *api* ]]; then
4+
echo "API worker excluded, skipping";
5+
exit 0;
6+
fi
7+
8+
IMMICH_HOST="${IMMICH_HOST:-localhost}"
9+
IMMICH_PORT="${IMMICH_PORT:-2283}"
10+
11+
result=$(curl -fsS -m 2 http://"$IMMICH_HOST":"$IMMICH_PORT"/api/server/ping)
12+
result_exit=$?
13+
14+
if [ $result_exit != 0 ]; then
15+
echo "Fail: exit code is $result_exit";
16+
exit 1;
17+
fi
18+
19+
if [ "$result" != "{\"res\":\"pong\"}" ]; then
20+
echo "Fail: didn't reply with pong";
21+
exit 1;
22+
fi

0 commit comments

Comments
 (0)