Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

feat(postgres,server): added healthcheck (#261)

Khiet Tam Nguyenf21de33532be
diff --git a/docker-compose.yml b/docker-compose.yml
index 3d90a740d..8f7f7561c 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -57,6 +57,12 @@ services:
- POSTGRES_DB=${POSTGRES_DB:-analytics}
volumes:
- postgres-data:/var/lib/postgresql/data
+ healthcheck:
+ test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
+ interval: 3s
+ timeout: 5s
+ retries: 5
+ start_period: 10s
restart: unless-stopped
backend:
@@ -85,6 +91,12 @@ services:
condition: service_healthy
postgres:
condition: service_started
+ healthcheck:
+ test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3001/health"]
+ interval: 3s
+ timeout: 5s
+ retries: 5
+ start_period: 10s
restart: unless-stopped
client:
diff --git a/docs/src/content/self-hosting-advanced.mdx b/docs/src/content/self-hosting-advanced.mdx
index 109504606..c27951ca0 100644
--- a/docs/src/content/self-hosting-advanced.mdx
+++ b/docs/src/content/self-hosting-advanced.mdx
@@ -90,8 +90,8 @@ _this setup assumes you have NPM docker up and running and are capable of creati
```
services:
rybbit_clickhouse:
- container_name: rybbit_clickhouse
image: clickhouse/clickhouse-server:25.4.2
+ container_name: rybbit_clickhouse
volumes:
- ./clickhouse-data:/var/lib/clickhouse
- ./clickhouse_config:/etc/clickhouse-server/config.d
@@ -118,6 +118,12 @@ services:
- POSTGRES_DB=${POSTGRES_DB:-analytics}
volumes:
- ./postgres-data:/var/lib/postgresql/data
+ healthcheck:
+ test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
+ interval: 3s
+ timeout: 5s
+ retries: 5
+ start_period: 10s
restart: unless-stopped
networks:
- internal
@@ -143,6 +149,12 @@ services:
condition: service_healthy
rybbit_postgres:
condition: service_started
+ healthcheck:
+ test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3001/health"]
+ interval: 3s
+ timeout: 5s
+ retries: 5
+ start_period: 10s
restart: unless-stopped
networks:
- internal
diff --git a/server/src/index.ts b/server/src/index.ts
index d3701880e..b3e4eb395 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -264,6 +264,7 @@ if (IS_CLOUD) {
}
server.post("/track", trackEvent);
+server.get("/health", (_, reply) => reply.send("OK"));
const start = async () => {
try {