Initial import

This commit is contained in:
how2ice
2026-04-21 03:33:23 +09:00
commit 9e4b70f1f1
495 changed files with 94680 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
import { env } from './config/env.js';
import { db } from './db/client.js';
import { createApp } from './app.js';
import { ChatService } from './services/chat-service.js';
import { clearAllChatConversationJobStates } from './services/chat-room-service.js';
import { shutdownNotificationProvider } from './services/notification-service.js';
import { PlanWorker } from './workers/plan-worker.js';
const app = createApp();
const planWorker = new PlanWorker(app.log);
const chatService = new ChatService(app.log);
app.server.on('upgrade', chatService.attachUpgradeHandler());
async function start() {
try {
await clearAllChatConversationJobStates();
await app.listen({
host: '0.0.0.0',
port: env.PORT,
});
planWorker.start();
} catch (error) {
app.log.error(error);
process.exit(1);
}
}
async function shutdown(signal: string) {
app.log.info(`Received ${signal}, closing server`);
await planWorker.stop();
chatService.close();
await app.close();
await shutdownNotificationProvider();
await db.destroy();
process.exit(0);
}
process.on('SIGINT', () => {
void shutdown('SIGINT');
});
process.on('SIGTERM', () => {
void shutdown('SIGTERM');
});
void start();