Skip to content

Commit 2ce70c0

Browse files
committed
docs: Add health check API documentation
Added comprehensive documentation for the /api/health endpoint, including usage examples for Docker Compose, Kubernetes, and Nginx.
1 parent 4ce474a commit 2ce70c0

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

docs/docs.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
"docs/configuration/audit-logs"
104104
]
105105
},
106+
{
107+
"group": "API Reference",
108+
"pages": [
109+
"docs/api/healthCheck"
110+
]
111+
},
106112
{
107113
"group": "Upgrade",
108114
"pages": [

docs/docs/api/healthCheck.mdx

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: Health Check API
3+
sidebarTitle: Health Check
4+
---
5+
6+
The Health Check API provides a simple endpoint to verify that the Sourcebot service is running and responsive. This endpoint is designed for use with monitoring systems, load balancers, container orchestration platforms (like Kubernetes), and reverse proxies (like nginx).
7+
8+
## Endpoint
9+
10+
```
11+
GET /api/health
12+
```
13+
14+
## Response
15+
16+
The endpoint returns a JSON response indicating the service status.
17+
18+
### Success Response
19+
20+
**Status Code:** `200 OK`
21+
22+
**Response Body:**
23+
```json
24+
{
25+
"status": "ok"
26+
}
27+
```
28+
29+
## Usage Examples
30+
31+
### cURL
32+
33+
```bash
34+
curl http://localhost:3000/api/health
35+
```
36+
37+
### Docker Compose
38+
39+
Add a health check to your `docker-compose.yml`:
40+
41+
```yaml
42+
services:
43+
sourcebot:
44+
image: sourcebot/sourcebot:latest
45+
healthcheck:
46+
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
47+
interval: 30s
48+
timeout: 10s
49+
retries: 3
50+
start_period: 40s
51+
```
52+
53+
### Kubernetes
54+
55+
Add a liveness and readiness probe to your Kubernetes deployment:
56+
57+
```yaml
58+
apiVersion: apps/v1
59+
kind: Deployment
60+
metadata:
61+
name: sourcebot
62+
spec:
63+
template:
64+
spec:
65+
containers:
66+
- name: sourcebot
67+
image: sourcebot/sourcebot:latest
68+
livenessProbe:
69+
httpGet:
70+
path: /api/health
71+
port: 3000
72+
initialDelaySeconds: 30
73+
periodSeconds: 10
74+
timeoutSeconds: 5
75+
failureThreshold: 3
76+
readinessProbe:
77+
httpGet:
78+
path: /api/health
79+
port: 3000
80+
initialDelaySeconds: 10
81+
periodSeconds: 5
82+
timeoutSeconds: 3
83+
failureThreshold: 3
84+
```
85+
86+
### Nginx
87+
88+
Configure Nginx to use the health check endpoint for upstream monitoring:
89+
90+
```nginx
91+
upstream sourcebot_backend {
92+
server sourcebot:3000 max_fails=3 fail_timeout=30s;
93+
}
94+
95+
server {
96+
listen 80;
97+
98+
location /api/health {
99+
proxy_pass http://sourcebot_backend/api/health;
100+
proxy_connect_timeout 5s;
101+
proxy_read_timeout 5s;
102+
}
103+
104+
location / {
105+
proxy_pass http://sourcebot_backend;
106+
}
107+
}
108+
```
109+
110+
## Notes
111+
112+
- The health check endpoint does not require authentication
113+
- The endpoint logs each health check request for monitoring purposes
114+
- A `200 OK` response indicates the web server is operational
115+
- This is a basic health check that verifies service responsiveness

0 commit comments

Comments
 (0)