import { spawn } from 'node:child_process'; import 'dotenv/config'; const children = [ spawn(process.execPath, ['--watch', 'server/index.mjs'], { stdio: 'inherit', env: { ...process.env, NODE_ENV: 'development', PORT: '3001' }, }), spawn(process.execPath, ['node_modules/vite/bin/vite.js'], { stdio: 'inherit', env: { ...process.env, NODE_ENV: 'development' }, }), ]; let stopping = false; function stop(code = 0) { if (stopping) return; stopping = true; for (const child of children) child.kill(); process.exitCode = code; } for (const child of children) child.on('exit', (code) => stop(code ?? 1)); process.on('SIGINT', () => stop()); process.on('SIGTERM', () => stop());