mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 08:17:11 +00:00
fix(web-server): run usage cleanup during dashboard shutdown
- pass server cleanup callback into graceful shutdown wiring - stop usage aggregator background sync when config server exits - prevent orphaned sync intervals across dashboard restarts
This commit is contained in:
@@ -160,10 +160,10 @@ export async function handleConfigCommand(args: string[]): Promise<void> {
|
||||
|
||||
try {
|
||||
// Start server
|
||||
const { server, wss } = await startServer({ port, dev: options.dev });
|
||||
const { server, wss, cleanup } = await startServer({ port, dev: options.dev });
|
||||
|
||||
// Setup graceful shutdown
|
||||
setupGracefulShutdown(server, wss);
|
||||
setupGracefulShutdown(server, wss, cleanup);
|
||||
|
||||
const url = `http://localhost:${port}`;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import { WebSocketServer } from 'ws';
|
||||
import { setupWebSocket } from './websocket';
|
||||
import { createSessionMiddleware, authMiddleware } from './middleware/auth-middleware';
|
||||
import { startAutoSyncWatcher, stopAutoSyncWatcher } from '../cliproxy/sync';
|
||||
import { shutdownUsageAggregator } from './usage/aggregator';
|
||||
|
||||
export interface ServerOptions {
|
||||
port: number;
|
||||
@@ -107,6 +108,7 @@ export async function startServer(options: ServerOptions): Promise<ServerInstanc
|
||||
const cleanup = () => {
|
||||
wsCleanup();
|
||||
stopAutoSyncWatcher().catch(() => {});
|
||||
shutdownUsageAggregator();
|
||||
};
|
||||
|
||||
// Start listening
|
||||
|
||||
Reference in New Issue
Block a user