()
| 6 | const pidFile = path.join(projectRoot, '.e2e-artifacts/.server.pid'); |
| 7 | |
| 8 | function stopServer() { |
| 9 | if (!fs.existsSync(pidFile)) { |
| 10 | return; |
| 11 | } |
| 12 | |
| 13 | try { |
| 14 | const pid = Number(fs.readFileSync(pidFile, 'utf8').trim()); |
| 15 | if (pid > 0) { |
| 16 | process.kill(pid, 'SIGTERM'); |
| 17 | } |
| 18 | } catch { |
| 19 | // ignore stale pid |
| 20 | } |
| 21 | |
| 22 | fs.rmSync(pidFile, { force: true }); |
| 23 | } |
| 24 | |
| 25 | module.exports = async () => { |
| 26 | try { |