import { spawn } from 'child_process'; import { dirname } from 'path'; import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); // Start the WebSocket server console.log('Starting WebSocket server'); const wsServer = spawn('node', ['src/websocket-server.js'], { stdio: 'inherit', shell: true, cwd: __dirname }); // Start the SvelteKit production server console.log('Starting SvelteKit production server'); const sveltekit = spawn('node', ['build/index.js'], { stdio: 'inherit', shell: true, cwd: __dirname }); // Handle process exit process.on('exit', () => { console.log('Shutting down servers...'); wsServer.kill(); sveltekit.kill(); }); // Handle ctrl+c process.on('SIGINT', () => { console.log('Received SIGINT, shutting down servers...'); wsServer.kill('SIGINT'); sveltekit.kill('SIGINT'); process.exit(0); }); // Handle termination process.on('SIGTERM', () => { console.log('Received SIGTERM, shutting down servers...'); wsServer.kill('SIGTERM'); sveltekit.kill('SIGTERM'); process.exit(0); });