add health check endpoint and update webserver routes
This commit is contained in:
@@ -9,4 +9,9 @@ services:
|
|||||||
- .:/app
|
- .:/app
|
||||||
ports:
|
ports:
|
||||||
- "$PORT:$PORT"
|
- "$PORT:$PORT"
|
||||||
command: sh -c "npm i -g pnpm && pnpm install && pnpm dev"
|
command: sh -c "npm i -g pnpm && pnpm install && pnpm dev"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:$PORT/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 1
|
||||||
7
src/web/health.ts
Normal file
7
src/web/health.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { Express } from 'express';
|
||||||
|
|
||||||
|
export default function healthRoute(app: Express) {
|
||||||
|
app.get('/health', (req, res) => {
|
||||||
|
res.status(200).send('ok');
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ export default async function webserver() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const IgnoredPaths = ['/favicon.ico', '/robots.txt', "/", "/hello"];
|
const IgnoredPaths = ['/favicon.ico', '/robots.txt', "/", "/hello"];
|
||||||
const KnownPaths = ["/git-commit", "/"];
|
const KnownPaths = ["/git-commit", "/", "/health"];
|
||||||
|
|
||||||
// log all incoming requests
|
// log all incoming requests
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user