"use strict";
/**
 * Shutdown Handler
 *
 * Handles SIGINT/SIGTERM signals to close server and exit immediately.
 * No graceful waiting - config dashboard doesn't need it.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupGracefulShutdown = void 0;
const ui_1 = require("../utils/ui");
/**
 * Setup shutdown handlers for SIGINT and SIGTERM
 */
function setupGracefulShutdown(server, _wss, cleanup) {
    const shutdown = () => {
        console.log('\n' + (0, ui_1.ok)('Shutting down...'));
        // Run cleanup (closes file watchers + WebSocket clients)
        if (cleanup) {
            cleanup();
        }
        // Close server and exit immediately
        server.close();
        process.exit(0);
    };
    process.on('SIGINT', shutdown);
    process.on('SIGTERM', shutdown);
}
exports.setupGracefulShutdown = setupGracefulShutdown;
//# sourceMappingURL=shutdown.js.map