(child)
| 28 | } |
| 29 | |
| 30 | async function stop(child) { |
| 31 | if (!child || child.exitCode !== null) { |
| 32 | return |
| 33 | } |
| 34 | |
| 35 | child.kill('SIGTERM') |
| 36 | await Promise.race([ |
| 37 | once(child, 'exit'), |
| 38 | new Promise((resolve) => setTimeout(resolve, 2000)), |
| 39 | ]) |
| 40 | |
| 41 | if (child.exitCode === null) { |
| 42 | child.kill('SIGKILL') |
| 43 | await Promise.race([ |
| 44 | once(child, 'exit'), |
| 45 | new Promise((resolve) => setTimeout(resolve, 2000)), |
| 46 | ]) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | async function run() { |
| 51 | const api = start('api', process.execPath, ['./server/index.mjs']) |