Reputation: 46589
I realize there are a lot of related questions on this. None that I've found address this question.
I'd like my process to restart with --debug
on when my code changes. Two commands in my package.json:
"debug-no-inspect": "API_PORT=5566 API_LOGLEVEL=DEBUG node --debug dist/index.js | bunyan -o short",
"watch": "watch 'npm run debug-no-inspect' ./src -d --wait=1",
OK those work nicely by themselves and work fine without --debug
, but together the --debug
will cause an EADDRINUSE error:
Error: listen EADDRINUSE :::5858
Increasing the time to 4 seconds didn't do it. It works fine if I Ctrl-C and kill the watch and restart but that defeats the purpose. Is there a way to programmatically release that debugger port before restarting the process without killing all my node processes?
My best stab at this so far: Add a silly env variable (ID=9877876
or FINDME=alksdjflaksjdfl
) to the start command and then use that to find the process later and kill it before restarting:
"watch": "watch 'kill $(ps a | grep [ID]=9877876 | cut -d \" \" -f 1) && npm run debug-no-inspect' ./src -d"
However this does not work. The command works by itself but not with watch
. Is another library a better choice?
Node 6; OSX; bash
Upvotes: 0
Views: 586