new node.js impl., removed old stuff
This commit is contained in:
48
email-worker-nodejs/health.ts
Normal file
48
email-worker-nodejs/health.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Health check HTTP server
|
||||
*
|
||||
* Provides a simple /health endpoint for Docker healthcheck
|
||||
* and monitoring. Returns domain list and feature flags.
|
||||
*/
|
||||
|
||||
import { createServer, type Server } from 'node:http';
|
||||
import { log } from './logger.js';
|
||||
|
||||
export function startHealthServer(
|
||||
port: number,
|
||||
domains: string[],
|
||||
getStats?: () => any,
|
||||
): Server {
|
||||
const server = createServer((_req, res) => {
|
||||
const stats = getStats?.() ?? {};
|
||||
|
||||
const payload = {
|
||||
status: 'healthy',
|
||||
worker: 'unified-email-worker-ts',
|
||||
version: '2.0.0',
|
||||
domains,
|
||||
domainCount: domains.length,
|
||||
features: {
|
||||
bounce_handling: true,
|
||||
ooo_replies: true,
|
||||
forwarding: true,
|
||||
blocklist: true,
|
||||
prometheus_metrics: true,
|
||||
lmtp: false,
|
||||
legacy_smtp_forward: false,
|
||||
},
|
||||
stats,
|
||||
uptime: process.uptime(),
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify(payload, null, 2));
|
||||
});
|
||||
|
||||
server.listen(port, () => {
|
||||
log(`Health check on port ${port}`);
|
||||
});
|
||||
|
||||
return server;
|
||||
}
|
||||
Reference in New Issue
Block a user