Stop listening for node.js

When I do:

node server.js

Then my terminal (osx) starts to listen for messages like errors and logs from the node app.

  1. How can I start node without listening?
  2. How can I stop listening programtically from within node.js?

If you are using bash shell (the typical default on a Unix-like operating system such as OS X), you can start it up like this:

node server.js 2>&1 >/dev/null

That directs STDERR and STDOUT to /dev/null.

If you also want to throw the process into the background so you can do other things in the shell, add a & at the end:

node server.js 2>&1 >/dev/null &

Just make sure you know how to bring it back to the foreground (fg command) and/or know how to kill it when you no longer want it running.