Skip to content

Instantly share code, notes, and snippets.

@eknkc
Created September 21, 2013 13:52
Show Gist options
  • Save eknkc/6650861 to your computer and use it in GitHub Desktop.
Save eknkc/6650861 to your computer and use it in GitHub Desktop.
var http = require("http");
var usta = require("../");
if (usta.isMaster) {
usta.setup({
silent: false
})
.pool("web", {
size: 2,
ttl: 10000
})
.pool("util", {
size: 1,
ttl: 50000,
strict: true,
heartbeatTimeout: 1000
})
} else {
usta.register("web", function () {
http.createServer(function (req, res) {
if (usta.disconnecting) {
res.writeHead(200, {'Content-Type': 'application/json', "Connection": 'close'});
} else {
res.writeHead(200, {'Content-Type': 'application/json'});
}
if (req.url == '/kill-self')
usta.kill();
if (req.url == '/kill-pool')
usta.kill({ pool: true });
if (req.url == '/kill-all')
usta.kill({ cluster: true });
if (req.url == '/restart-self')
usta.restart();
if (req.url == '/restart-pool')
usta.restart({ pool: true });
if (req.url == '/restart-all')
usta.restart({ cluster: true });
setTimeout(function() {
res.end(JSON.stringify(process.pid, null, " "));
}, 100);
}).listen(2593);
})
usta.register("util", function () {
setTimeout(function () {
console.log("util process is running");
}, 5000);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment