I\'ve installed and is running a node.js server on osx. I\'ve dled a chat module and is happily running it. I\'ve altered some pieces and need to restart the server to see t
In this case you are restarting your node.js server often because it's in active development and you are making changes all the time. There is a great hot reload script that will handle this for you by watching all your .js files and restarting your node.js server if any of those files have changed. Just the ticket for rapid development and test.
The script and explanation on how to use it are at here at Draco Blue.
If it's just running (not a daemon) then just use Ctrl-C
.
If it's daemonized then you could try:
$ ps aux | grep node
you PID 1.5 0.2 44172 8260 pts/2 S 15:25 0:00 node app.js
$ kill -2 PID
Where PID
is replaced by the number in the output of ps
.
I had the same problem and then wrote this shell script which kills all of the existing node processes:
#!/bin/bash
echo "The following node processes were found:"
ps aux | grep " node " | grep -v grep
nodepids=$(ps aux | grep " node " | grep -v grep | cut -c10-15)
echo "OK, so we will stop these process/es now..."
for nodepid in ${nodepids[@]}
do
echo "Stopping PID :"$nodepid
kill -9 $nodepid
done
echo "Done"
After this is saved as a shell script (xxx.sh) file you might want to add it to your PATH as described here.
(Please note that this will kill all of the processes with " node " in it's name except grep's own, so I guess in some cases it may also kill some other processes with a similar name)