Created
October 15, 2014 15:23
-
-
Save XadillaX/d6ebecda7f408b0c186c to your computer and use it in GitHub Desktop.
MySQL Daemon in ACM.NBUT.EDU.CN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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