You build node.js app with express v4.x then start your app by npm start. My question is how to stop the app? Is there npm stop?
EDIT to include the error when implement npm stop
/home/nodetest2# npm stop
> [email protected] stop /home/nodetest2
> pkill -s SIGINT nodetest2
pkill: invalid argument for option 's' -- SIGINT
npm ERR! [email protected] stop: `pkill -s SIGINT nodetest2`
npm ERR! Exit status 2
Yes, npm provides for a stop script too:
npm help npm-scripts
prestop, stop, poststop: Run by the npm stop command.
Set one of the above in your package.json, and then use npm stop
npm help npm-stop
You can make this really simple if you set in app.js
,
process.title = myApp;
And, then in scripts.json,
"scripts": {
"start": "app.js"
, "stop": "pkill --signal SIGINT myApp"
}
That said, if this was me, I'd be using pm2
or something the automatically handled this on the basis of a git push.