first commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { createServer } from 'node:net';
|
||||
import { spawn } from 'node:child_process';
|
||||
|
||||
const check = (port) => new Promise((resolve, reject) => {
|
||||
const server = createServer();
|
||||
server.once('error', reject);
|
||||
server.listen(port, '127.0.0.1', () => server.close(resolve));
|
||||
});
|
||||
|
||||
for (const port of [8765, 5174]) {
|
||||
try { await check(port); }
|
||||
catch { console.error(`Port ${port} is in use. Stop that process or choose another port before starting.`); process.exit(1); }
|
||||
}
|
||||
const child = spawn('npm', ['run', 'dev:servers'], { stdio: 'inherit', shell: process.platform === 'win32' });
|
||||
child.on('exit', code => process.exit(code ?? 0));
|
||||
for (const signal of ['SIGINT', 'SIGTERM']) process.on(signal, () => child.kill(signal));
|
||||
Reference in New Issue
Block a user