-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhaproxy.js
More file actions
55 lines (51 loc) · 1.6 KB
/
haproxy.js
File metadata and controls
55 lines (51 loc) · 1.6 KB
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
43
44
45
46
47
48
49
50
51
52
53
var haproxyMod = new require('haproxy'),
compiler = require('./compiler'),
HAProxy = haproxyMod({
config : __dirname + '/tempfiles/haproxy.cfg',
pidFile : __dirname + '/tempfiles/haproxy.pid'
});
module.exports = {
init : function (cb) {
var self = this;
cb = cb || function(){};
var all = true; // Kill all running Haproxy
console.log('Killing all running Haproxy');
HAProxy.stop(all, function(err){
compiler(); //Compile and create the HAP config
self.start(cb);
});
},
restart : function (cb) {
/*HAProxy.reload(function (err) {
if(err) {console.log(err); return cb(err);}
else console.log(' .. HAP reloaded ..');
cb();
});*/
var self = this;
cb = cb || function(){};
//HAProxy.softstop(function(err){
HAProxy.stop(function(err){
if(err) {console.log(err); return cb(err);}
console.log(' .. HAP softstoped. Starting it..');
self.start(cb);
});
},
start : function(cb) {
var self = this;
cb = cb || function(){};
self.verify(function(err){
if(err){return cb(err);}
HAProxy.start(function (err) {
if(err) {console.log(err); return cb(err);}
else console.log(' .. HAP started ..');
});
});
},
verify : function(cb) {
cb = cb || function(){};
HAProxy.verify(function (err, working) {
if(err) {console.log(err);}
cb(err, working);
});
}
};