feat(server): graceful shutdown for AI streams (#10025)

https://github.com/user-attachments/assets/8dd3c4f5-4059-4f03-9f51-68078d7ab5c4
This commit is contained in:
Brooooooklyn
2025-02-07 11:25:02 +00:00
parent 0df94b8e35
commit 4e00ddd5f1
3 changed files with 42 additions and 12 deletions

View File

@@ -44,6 +44,11 @@ export async function createApp() {
app.useGlobalInterceptors(app.get(CacheInterceptor));
app.useGlobalFilters(new GlobalExceptionFilter(app.getHttpAdapter()));
app.use(cookieParser());
// only enable shutdown hooks in production
// https://docs.nestjs.com/fundamentals/lifecycle-events#application-shutdown
if (AFFiNE.NODE_ENV === 'production') {
app.enableShutdownHooks();
}
const adapter = new SocketIoAdapter(app);
app.useWebSocketAdapter(adapter);