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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With