Created
September 2, 2014 13:38
-
-
Save maksadbek/9459c545a8176812f1ca to your computer and use it in GitHub Desktop.
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 info = "[info]....."+Date()+" "; | |
var warning = "[warning].."+Date()+" "; | |
var notice = "[notice]..."+Date()+" "; | |
var exec = require("child_process").exec, child; | |
var socket = require("socket.io-client")("http://localhost:8080"); | |
console.log(info+"start"); | |
socket.on("connect", function(){ | |
console.log(info+"connected"); | |
}) | |
function reset(){ | |
child = exec("service nginx restart", | |
function(error, stdout, stderr){ | |
console.log("stdout: "+stdout); | |
console.log("stderr: "+stderr); | |
if(error != null){ | |
console.log("exec error: "+error); | |
} | |
} | |
); | |
} | |
socket.on("timeout", function(){ | |
console.log(info+"timeout"); | |
console.log(info+"reset"); | |
reset(); | |
}) | |
socket.on("disconnect", function(){ | |
console.log(info+"disconnect"); | |
console.log(info+"reset"); | |
reset(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment