feat: Migrate data storage to PostgreSQL with schema setup, initialization script, and update documentation
This commit is contained in:
31
src/index.ts
31
src/index.ts
@@ -5,6 +5,7 @@
|
||||
|
||||
import { mcpServer } from "./server.js";
|
||||
import { logger } from "./utils/logger.js";
|
||||
import { database } from "./storage/database.js";
|
||||
|
||||
// Register all tools
|
||||
import { registerCodeSnippetTools } from "./tools/programming/codeSnippet.js";
|
||||
@@ -57,10 +58,30 @@ registerNoteTools();
|
||||
registerTaskTools();
|
||||
registerEmailTools();
|
||||
|
||||
logger.info("All tools registered. Starting MCP server...");
|
||||
logger.info("All tools registered. Initializing database...");
|
||||
|
||||
// Start the server
|
||||
mcpServer.start().catch((error) => {
|
||||
logger.error("Failed to start MCP server:", error);
|
||||
process.exit(1);
|
||||
// Initialize database connection
|
||||
database
|
||||
.initialize()
|
||||
.then(() => {
|
||||
logger.info("Database connected successfully. Starting MCP server...");
|
||||
// Start the server
|
||||
return mcpServer.start();
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error("Failed to initialize database or start MCP server:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Graceful shutdown
|
||||
process.on("SIGINT", async () => {
|
||||
logger.info("Shutting down...");
|
||||
await database.close();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on("SIGTERM", async () => {
|
||||
logger.info("Shutting down...");
|
||||
await database.close();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user