I have written a test script which runs another script to start the server to test. When the tests have completed a SIGKILL
message is sent to the server process, however when running the test script again the server throws a EADDRINUSE
error (I‘m in a node.js environment) which means the port the server is trying to mount to is currently in use. The process we tried to kill with a SIGKILL
is still running. I don‘t believe this is a node specific issue, but rather a lack of education on my end for how bash processes work.
Here are some specifics, this is my start script called scripts/start-node.sh
:
#!/bin/bash
node_modules/.bin/babel-node --stage 0 index.js
This is my node server called index.js
(I haven‘t authored any process
event listeners):
Http.createServer(…).listen(PORT, () => console.log(`Server listening on ${PORT}`))
And the start script is controlled with the node child_process
module:
var child = child_process.spawn('scripts/start-node.sh')
// Later…
child.kill('SIGKILL')
child.kill('SIGINT')
maybe node doesn't support theSIGKILL
signal, and will then assume default to:SIGTERM
: nodejs.org/api/… – StringfellowSIGINT
,SIGKILL
,SIGHUP
,SIGQUIT
, andSIGTERM
. From what I‘ve read,SIGKILL
seems like the most semantic way to do it. – Ot.close()
instead of killing the process? – Ryon.close()
documented here – Ot