Skip to content

Instantly share code, notes, and snippets.

@XadillaX
Created October 15, 2014 15:23
Show Gist options
  • Save XadillaX/d6ebecda7f408b0c186c to your computer and use it in GitHub Desktop.
Save XadillaX/d6ebecda7f408b0c186c to your computer and use it in GitHub Desktop.
MySQL Daemon in ACM.NBUT.EDU.CN
var exec = require("child_process").exec;
function check() {
exec("pgrep mysql", function(err, stdout, stderr) {
if(err) {
if(err.message.indexOf("Command failed") !== -1) {
console.log("Restarting mysqld...");
return exec("service mysqld start", function(err, stdout, stderr) {
if(err) console.log(err);
if(stdout) console.log(stdout);
if(stderr) console.log(stderr);
console.log("Restarted.");
setTimeout(check, 1000);
});
}
return setTimeout(check, 1000);
}
setTimeout(check, 10 * 1000);
});
}
check();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment