From 64741650eb52fe874d6eda404dd54e80ded19c0b Mon Sep 17 00:00:00 2001 From: gustaff-weldon Date: Tue, 23 Nov 2021 16:39:48 +0100 Subject: [PATCH] feat(server): Wait for server to exit when stopping it --- src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7ec5732..a6b2a96 100644 --- a/src/index.js +++ b/src/index.js @@ -65,7 +65,12 @@ function waitAndRun ({ start, url, runFn }) { }) .then(() => { debug('stopping server') - server.kill() + return new Promise((resolve, reject) => { + server.kill('SIGINT', { forceKillAfterTimeout: 10000 }) + server.on('exit', () => { + resolve() + }) + }) }) } }