Update index.ts
This commit is contained in:
parent
a3e9af1a65
commit
c2096ae746
23
src/index.ts
23
src/index.ts
|
@ -111,6 +111,29 @@ const mcpServer = new DiscordMCPServer(client, transport);
|
||||||
try {
|
try {
|
||||||
await mcpServer.start();
|
await mcpServer.start();
|
||||||
info('MCP server started successfully');
|
info('MCP server started successfully');
|
||||||
|
|
||||||
|
// Keep the Node.js process running
|
||||||
|
if (config.TRANSPORT.toLowerCase() === 'http') {
|
||||||
|
// Send a heartbeat every 30 seconds to keep the process alive
|
||||||
|
setInterval(() => {
|
||||||
|
info('MCP server is running');
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
|
// Handle termination signals
|
||||||
|
process.on('SIGINT', async () => {
|
||||||
|
info('Received SIGINT. Shutting down server...');
|
||||||
|
await mcpServer.stop();
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('SIGTERM', async () => {
|
||||||
|
info('Received SIGTERM. Shutting down server...');
|
||||||
|
await mcpServer.stop();
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
info('Server running in keep-alive mode. Press Ctrl+C to stop.');
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error('Failed to start MCP server: ' + String(err));
|
error('Failed to start MCP server: ' + String(err));
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
Loading…
Reference in New Issue