23 lines
580 B
JavaScript
23 lines
580 B
JavaScript
import { spawn } from 'node:child_process';
|
|
|
|
const commands = [
|
|
['node', ['server/cms-server.mjs']],
|
|
['npm', ['run', 'dev', '--', '--host', '127.0.0.1']],
|
|
];
|
|
|
|
const children = commands.map(([cmd, args]) => {
|
|
const child = spawn(cmd, args, { stdio: 'inherit', shell: false });
|
|
child.on('exit', (code) => {
|
|
if (code && code !== 0) {
|
|
children.forEach((item) => item.pid !== child.pid && item.kill());
|
|
process.exit(code);
|
|
}
|
|
});
|
|
return child;
|
|
});
|
|
|
|
process.on('SIGINT', () => {
|
|
children.forEach((child) => child.kill('SIGINT'));
|
|
process.exit(0);
|
|
});
|