I'm trying to set up a build-system for Node.js on sublime, so I can press F7 to call "node" on the openned file. The problem is that the process is then open forever, so, the second time I use F7 I get an add-in-use.
Is there a way I can kill the openned "node.exe" process from node.js?
Use the following set of commands to identify the process running on a given port and to termiate it from the command line
It will output details similar to the one shown below
Then use
to terminate the process. Check once again using
to ensure that the process has terminated.
On Windows you could use the following steps
Note the PID corresponding to your node process, in this case 3592. Next run taskkill to terminate the process.
Or /IM switch
Similarly to what @Alex W said, you can send a kill signal to the process so long as you have its process ID, or PID using the following node function:
process.kill(pid, [signal])
In my case, I had the PIDs readily available as I was spawning
child_process().spawn.pid
. I have tested it and it does work on Win 7 x64.From within Node.js:
There are certain methods available for exiting that are only available for POSIX (i.e. not Windows) that will exit a process by its process id.
Also, note that you might be able to send a kill() signal using this method, which does not say it isn't available for Windows:
if you want to kill all process than
if you want to kill process on selected port than
here 3100 is port
If sublime you say is sublimeText plugin, I have the same issue, and send TCP server a message 'shutdown' from python code, then
app.js