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:
1 2 3 4 5 |
var sys = require('sys'); var exec = require('child_process').exec; function puts(error, stdout, stderr) { sys.puts(stdout) } exec("~/path/to/nodejs/restartscript.sh", puts); |
You can also choose to output something back to the client if need be.