NodeJS – Execute a Shell Script / Command

Mar 10

So on my continued quest to build an awesome shoutbox in NodeJS + socket.io, I have discovered how to run shell scripts from NodeJS. This was a request from one of the staff members on DarkUmbra.Net to be able to restart the server if something messes up. What resulted was a shell script that restarts NodeJS and whatever server you are running.

This is the NodeJS code to do this:

You can also choose to output something back to the client if need be.

Filed Under: Dev