A /health endpoint for the Docker health checks
The health checks of web, seed-api and seed-relay called /api/v1/stats every 30 s, whose release statistics query kept about a core busy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f8ee7e8662
commit
06de0f21c5
2 files changed
+16
No files matched your search
@@ -9,12 +9,20 @@
|
||||
|
||||
import { middleware } from '#start/kernel'
|
||||
import router from '@adonisjs/core/services/router'
|
||||
import db from '@adonisjs/lucid/services/db'
|
||||
import { controllers } from '#generated/controllers'
|
||||
|
||||
const ReleasesController = () => import('#controllers/releases_controller')
|
||||
const NewznabController = () => import('#controllers/newznab_controller')
|
||||
const SeedController = () => import('#controllers/seed_controller')
|
||||
|
||||
// Docker health checks (web, seed-api, seed-relay): the database answers, nothing more. They called
|
||||
// /api/v1/stats every 30 s from five containers, and its query kept a core busy (LOG.md 2026-10-07 (5)).
|
||||
router.get('/health', async () => {
|
||||
await db.rawQuery('SELECT 1')
|
||||
return { ok: true }
|
||||
})
|
||||
|
||||
// Newznab API for Prowlarr / Sonarr / Radarr ("Generic Newznab", API path /api).
|
||||
router.get('/api', [NewznabController, 'handle'])
|
||||
|
||||
|
||||
@@ -135,3 +135,11 @@ test.group('Web API', (group) => {
|
||||
assert.isTrue(row.par2Only)
|
||||
})
|
||||
})
|
||||
|
||||
test.group('Health check', () => {
|
||||
test('/health answers when the database does', async ({ client }) => {
|
||||
const response = await client.get('/health')
|
||||
response.assertStatus(200)
|
||||
response.assertBody({ ok: true })
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user