From 351578a8767f8faa06a26eeace168622503e7682 Mon Sep 17 00:00:00 2001 From: incubator4 Date: Thu, 15 Aug 2024 11:29:48 +0800 Subject: [PATCH] feat(core): add healthz route for server health check (#16450) --- docker-compose.yml | 38 +++++++++++++++++++++++++++----------- lib/registry.ts | 1 + 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 576c436e7..8b79ddf80 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,29 +6,45 @@ services: image: diygod/rsshub restart: always ports: - - '1200:1200' + - "1200:1200" environment: NODE_ENV: production CACHE_TYPE: redis - REDIS_URL: 'redis://redis:6379/' - PUPPETEER_WS_ENDPOINT: 'ws://browserless:3000' # marked + REDIS_URL: "redis://redis:6379/" + PUPPETEER_WS_ENDPOINT: "ws://browserless:3000" # marked + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:1200/healthz"] + interval: 30s + timeout: 10s + retries: 3 depends_on: - redis - - browserless # marked + - browserless # marked - browserless: # marked - image: browserless/chrome # marked - restart: always # marked - ulimits: # marked - core: # marked - hard: 0 # marked - soft: 0 # marked + browserless: # marked + image: browserless/chrome # marked + restart: always # marked + ulimits: # marked + core: # marked + hard: 0 # marked + soft: 0 # marked + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3000/pressure"] + interval: 30s + timeout: 10s + retries: 3 redis: image: redis:alpine restart: always volumes: - redis-data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 30s + timeout: 10s + retries: 5 + start_period: 5s volumes: redis-data: diff --git a/lib/registry.ts b/lib/registry.ts index 0eb993518..9711fb8b3 100644 --- a/lib/registry.ts +++ b/lib/registry.ts @@ -100,6 +100,7 @@ for (const namespace in namespaces) { } app.get('/', index); +app.get('/healthz', (ctx) => ctx.text('ok')); app.get('/robots.txt', robotstxt); if (config.debugInfo) { // Only enable tracing in debug mode