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?
When I tried the suggested solution I realized that my app name was truncated. I read up on process.title
in the nodejs documentation (https://nodejs.org/docs/latest/api/process.html#process_process_title) and it says
On Linux and OS X, it's limited to the size of the binary name plus the length of the command line arguments because it overwrites the argv memory.
My app does not use any arguments, so I can add this line of code to my app.js
process.title = process.argv[2];
and then add these few lines to my package.json
file
"scripts": {
"start": "node app.js this-name-can-be-as-long-as-it-needs-to-be",
"stop": "killall -SIGINT this-name-can-be-as-long-as-it-needs-to-be"
},
to use really long process names. npm start
and npm stop
work, of course npm stop
will always terminate all running processes, but that is ok for me.