Find Node JS instance on Ubuntu

て烟熏妆下的殇ゞ 提交于 2019-12-10 11:15:37

问题


I wrote a script without putting process.exit(0) after I looked out for the ctrl c, process.on('SIGNIT', gracefulShutdown)

I want to know if the process is still running on my machine, I used:

ps -aux | grep node

It came up with something but i'm not sure what it is.

All I want to do is find a quick easy way of finding the process and kill it.

Thanks


回答1:


Example of output from ps -aux | grep node:

foo      22210  0.0  0.5 779600 46088 pts/2    Sl   Jan22   2:29 node ./server.js localhost:9999
foo      22794  0.0  0.0 692468   112 pts/4    Sl   Jan31   0:00 node ./static.js

These show two servers I've started. The process id is in the 2nd column so if I want to end the server that is running server.js, then:

kill 22210

If that does not work:

kill -9 22210

Generally speaking, I prefer to start with the kill without a signal option, which sends a TERM signal. If that does not work, then -9, which sends KILL. In the general case, TERM will give a chance to the process to terminate cleanly.



来源:https://stackoverflow.com/questions/21575808/find-node-js-instance-on-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!