To stop Node.js Express app that’s started with ‘npm start’, we use the pkill
command.
For instance, in package.json, we add
{
//...
"scripts": {
"start": "app.js",
"stop": "pkill --signal SIGINT myApp"
}
//...
}
to add a stop script that runs pkill
with the SIGINT signal to stop the myApp
app.
We use myApp
to kill app.js since we set process.title
to 'myApp'
in app.js.