Linux 找不到 node.js 应用程序在哪里运行并且无法杀死它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20091433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't find out where does a node.js app running and can't kill it
提问by yuyue007
What I did:I have just set up node environment, installed express, create and installed an express project
我做了什么:我刚刚设置了node环境,安装了express,创建并安装了一个express项目
express hello
cd hello && npm install
then started the app with "node app
".
然后用“ node app
”启动应用程序。
Environment:
环境:
yole@Yole:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.2 (wheezy)
Release: 7.2
Codename: wheezy
yole@Yole:~$ node --version
v0.10.22
yole@Yole:~$ express --version
3.4.4
ProblemWhen I want to stop this app, I used CTRL+C,
but the thing I found is it did not stopped. Then I restarted the server! I found I can still access the page in browser. Orz.
问题当我想停止这个应用程序时,我使用了CTRL+C,
但我发现它没有停止。然后我重新启动了服务器!我发现我仍然可以在浏览器中访问该页面。奥兹。
I have tried the following thing but still can't find out the running process.
我已经尝试了以下事情,但仍然无法找到正在运行的过程。
yole@Yole:~$ killall node
node: no process found
yole@Yole:~$ ps -ef|grep node
yole 3161 2888 0 16:57 pts/1 00:00:00 grep node
yole@Yole:~$ netstat -apn|grep 3000
QuestionHow to find out the running node process or how to kill it.
问题如何找出正在运行的节点进程或如何杀死它。
===== updateIt is very strange that all browses in my machine can visit the site while it's not available on other machine! I only visit the page with Chrome before I stop the application. It seems to be a cache problem, but how cache shared among browsers..
====== update很奇怪,我的机器上所有的浏览都可以访问该站点,而在其他机器上不可用!我只在停止应用程序之前使用 Chrome 访问该页面。这似乎是一个缓存问题,但是浏览器之间如何共享缓存..
回答by Damodaran
List node process:
列出节点进程:
$ ps -e|grep node
Kill the process using
使用杀死进程
$kill -9 XXXX
Here XXXX is the process number
这里XXXX是进程号
回答by ConfusedDeer
You can kill all node processes using pkill node
您可以使用以下命令杀死所有节点进程 pkill node
or you can do a ps T
to see all processes on this terminal
then you can kill a specific process ID doing a kill [processID]
example: kill 24491
或者您可以执行 aps T
以查看此终端上的所有进程,
然后您可以杀死特定的进程 ID,kill [processID]
例如:kill 24491
Additionally, you can do a ps -help
to see all the available options
此外,您可以执行 aps -help
查看所有可用选项
回答by Gin
If all those kill process commands don't work for you, my suggestion is to check if you were using any other packages to run your node process.
如果所有这些 kill process 命令都对您不起作用,我的建议是检查您是否使用任何其他包来运行您的节点进程。
I had the similar issue, and it was due to I was running my node process using PM2(a NPM package). The kill [processID]
command disables the process but keeps the port occupied. Hence I had to go into PM2 and dump all node process to free up the port again.
我遇到了类似的问题,这是因为我使用 PM2(一个 NPM 包)运行我的节点进程。该kill [processID]
命令禁用进程但保持端口被占用。因此我不得不进入 PM2 并转储所有节点进程以再次释放端口。
回答by Bhaurao Birajdar
If you want know, the how may nodejs processes running then you can use this command
如果您想知道 nodejs 进程如何运行,那么您可以使用此命令
ps -aef | grep node
So it will give list of nodejs process with it's project name. It will be helpful when you are running multipe nodejs application & you want kill specific process for the specific project.
所以它会给出带有项目名称的nodejs进程列表。当您运行 multipe nodejs 应用程序并且想要终止特定项目的特定进程时,这将很有帮助。
Above command will give output like
上面的命令将给出类似的输出
XXX 12886 1741 1 12:36 ? 00:00:05 /home/username/.nvm/versions/node/v9.2.0/bin/node --inspect-brk=43443 /node application running path.
So to kill you can use following command
所以要杀死你可以使用以下命令
kill -9 12886
So it will kill the spcefic node process
所以它会杀死 spcefic 节点进程
回答by Johan Hoeksma
I use fkill
我用fkill
INSTALL
安装
npm i fkill-cli -g
EXAMPLES
例子
Search process in command line
命令行中的搜索过程
fkill
OR: kill ! ALL process
或:杀!全部流程
fkill node
OR: kill process using port 8080
或:使用端口 8080 终止进程
fkill :8080