Restructure omni services and add Chatwoot research snapshot
This commit is contained in:
36
omni_chat/src/index.ts
Normal file
36
omni_chat/src/index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { createServer } from "node:http";
|
||||
|
||||
const port = Number(process.env.PORT || 8090);
|
||||
const service = "omni_chat";
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
if (req.method === "GET" && req.url === "/health") {
|
||||
const payload = JSON.stringify({
|
||||
ok: true,
|
||||
service,
|
||||
receiverFlow: process.env.RECEIVER_FLOW_QUEUE_NAME || "receiver.flow",
|
||||
senderFlow: process.env.SENDER_FLOW_QUEUE_NAME || "sender.flow",
|
||||
now: new Date().toISOString(),
|
||||
});
|
||||
res.statusCode = 200;
|
||||
res.setHeader("content-type", "application/json; charset=utf-8");
|
||||
res.end(payload);
|
||||
return;
|
||||
}
|
||||
|
||||
res.statusCode = 404;
|
||||
res.setHeader("content-type", "application/json; charset=utf-8");
|
||||
res.end(JSON.stringify({ ok: false, error: "not_found" }));
|
||||
});
|
||||
|
||||
server.listen(port, "0.0.0.0", () => {
|
||||
console.log(`[omni_chat] listening on :${port}`);
|
||||
});
|
||||
|
||||
function shutdown(signal: string) {
|
||||
console.log(`[omni_chat] shutting down by ${signal}`);
|
||||
server.close(() => process.exit(0));
|
||||
}
|
||||
|
||||
process.on("SIGINT", () => shutdown("SIGINT"));
|
||||
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
||||
Reference in New Issue
Block a user