The following trivial script exits immediately:
process.on('message', function () { });
What is the correct way to keep a node.js process running while listening for messages?
You could always do process.stdin.resume();
which will hold your process open until EOF is received on stdin or you explicitly exit (the stdin stream is initially paused to prevent this from happening unless you really want it to).