如何停止node.js表示'npm start'的应用 [英] How to stop app that node.js express 'npm start'
问题描述
您使用Express v4.x构建node.js应用,然后通过 npm start 启动您的应用.我的问题是如何停止该应用程序? npm停车吗?
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?
编辑,以在实施 npm stop
/home/nodetest2# npm stop
> nodetest2@0.0.1 stop /home/nodetest2
> pkill -s SIGINT nodetest2
pkill: invalid argument for option 's' -- SIGINT
npm ERR! nodetest2@0.0.1 stop: `pkill -s SIGINT nodetest2`
npm ERR! Exit status 2
推荐答案
是的,npm也提供了停止脚本:
Yes, npm provides for a stop script too:
npm help npm-scripts
停止,停止,后停止:由npm stop命令运行.
prestop, stop, poststop: Run by the npm stop command.
在package.json中设置以上内容之一,然后使用npm stop
Set one of the above in your package.json, and then use npm stop
npm help npm-stop
如果在app.js
中进行设置,您可以使其变得非常简单
You can make this really simple if you set in app.js
,
process.title = myApp;
process.title = myApp;
然后在scripts.json中
And, then in scripts.json,
"scripts": {
"start": "app.js"
, "stop": "pkill --signal SIGINT myApp"
}
也就是说,如果这是我,我会使用pm2
或基于git push自动处理的内容.
That said, if this was me, I'd be using pm2
or something the automatically handled this on the basis of a git push.
这篇关于如何停止node.js表示'npm start'的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!