handle server errors (#91)

This commit is contained in:
Olivier Chafik 2025-12-08 18:45:31 +01:00 • committed by GitHub
commit 3dde360dc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 50 additions and 10 deletions

View file

@ -153,7 +153,11 @@ app.post("/mcp", async (req, res) => {
await transport.handleRequest(req, res, req.body);
});
app.listen(3001, () => {
app.listen(3001, (err) => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log("Server listening on http://localhost:3001/mcp");
});
```

View file

@ -70,11 +70,19 @@ sandboxApp.use((_req, res) => {
});
// ============ Start both servers ============
hostApp.listen(HOST_PORT, () => {
hostApp.listen(HOST_PORT, err => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(`Host server: http://localhost:${HOST_PORT}`);
});
sandboxApp.listen(SANDBOX_PORT, () => {
sandboxApp.listen(SANDBOX_PORT, err => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(`Sandbox server: http://localhost:${SANDBOX_PORT}`);
console.log("\nPress Ctrl+C to stop\n");
});

View file

@ -85,7 +85,11 @@ app.post("/mcp", async (req: Request, res: Response) => {
}
});
const httpServer = app.listen(PORT, () => {
const httpServer = app.listen(PORT, err => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(`Server listening on http://localhost:${PORT}/mcp`);
});

View file

@ -85,7 +85,11 @@ app.post("/mcp", async (req: Request, res: Response) => {
}
});
const httpServer = app.listen(PORT, () => {
const httpServer = app.listen(PORT, err => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(`Server listening on http://localhost:${PORT}/mcp`);
});

View file

@ -330,7 +330,11 @@ async function main() {
}
});
const httpServer = app.listen(PORT, () => {
const httpServer = app.listen(PORT, (err) => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(
`Budget Allocator Server listening on http://localhost:${PORT}/mcp`,
);

View file

@ -240,7 +240,11 @@ async function main() {
}
});
const httpServer = app.listen(PORT, () => {
const httpServer = app.listen(PORT, (err) => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(
`Cohort Heatmap Server listening on http://localhost:${PORT}/mcp`,
);

View file

@ -139,7 +139,11 @@ async function main() {
}
});
const httpServer = app.listen(PORT, () => {
const httpServer = app.listen(PORT, (err) => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(
`Customer Segmentation Server listening on http://localhost:${PORT}/mcp`,
);

View file

@ -346,7 +346,11 @@ async function main() {
}
});
const httpServer = app.listen(PORT, () => {
const httpServer = app.listen(PORT, (err) => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(
`SaaS Scenario Modeler Server listening on http://localhost:${PORT}/mcp`,
);

View file

@ -211,7 +211,11 @@ async function main() {
}
});
const httpServer = app.listen(PORT, () => {
const httpServer = app.listen(PORT, (err) => {
if (err) {
console.error("Error starting server:", err);
process.exit(1);
}
console.log(
`System Monitor Server listening on http://localhost:${PORT}/mcp`,
);