forked from Stii/nodervisor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax_supervisord.js
42 lines (39 loc) · 940 Bytes
/
ajax_supervisord.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* GET supervisords json data
*/
exports.ajax_supervisord = function(params) {
var config = params.config;
var supervisordapi = params.supervisordapi;
var async = require('async');
return function(req, res) {
if (!req.session.loggedIn) {
res.send({error: 'Not logged in'});
} else {
var supervisords = {};
var hosts = [];
for (var idHost in config.hosts) {
hosts.push(config.hosts[idHost]);
}
async.each(hosts, function(host, callback){
var supclient = supervisordapi.connect(host.Url);
var processinfo = supclient.getAllProcessInfo(function(err, result){
if (err === null) {
supervisords[host.idHost] = {
host: host,
data: result
};
return callback();
} else {
supervisords[host.idHost] = {
host: host,
data: err
};
return callback();
}
});
}, function(err){
res.send(supervisords);
});
}
};
};