Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding process id of a Node.js server in Windows

To find a process id of a node.js server in unix, we use below code:

if (process.getgid) {
   console.log('Current gid: ' + process.getgid());
}

So I get output as 1888 in *nix OS, but when I execute same in Windows OS, I am getting output as undefined also as per node.js docs they have explicitly mentioned this method won't work in windows.

So my question, is there anyway I can get process id in windows os? I tried to execute taskkill /f /im node.exe but it kills all node processes, but I want to kill only particualr process. Is there anyway to achieve this?

like image 344
Pradeep Simha Avatar asked May 09 '13 12:05

Pradeep Simha


2 Answers

on windows process.pid works for me.

regarding the docs, getgid is not returning the Process ID, rather the group identity of the process, to get the process id use pid

To kill the process use:

taskkill /f /pid processID
like image 186
balazs Avatar answered Sep 21 '22 23:09

balazs


Use tasklist to find the correct ID...

You can then use taskkill when you sort through the correct id to kill that particular one. Not entirely sure if it'd work in node. But it's something that'd work on the CMD.

like image 35
FullOnFlatWhite Avatar answered Sep 23 '22 23:09

FullOnFlatWhite