-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared_helper.js
More file actions
63 lines (53 loc) · 1.04 KB
/
shared_helper.js
File metadata and controls
63 lines (53 loc) · 1.04 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
54
55
56
57
58
59
60
61
62
63
var helper = {
request:require('request'),
callStep:function(step, process, done)
{
try
{
this.isClientUp(step.ip, step.port, function(e){
if (!e)
{
this.request.post({url:'http://' + step.ip + ':' + step.port + '/process?step_key=' + step.key, json:process}, function(e, response, body){
if (e)
{
done(e);
}
else
{
done(null);
}
}.bind(this));
}
}.bind(this));
}
catch(e)
{
done(e);
}
},
isClientUp:function(ip, port, done)
{
try
{
console.log('checking if up...' + ip + ' ' + port);
this.request.get({url:'http://' + ip + ':' + port + '/up'}, function(e, response, body){
if (e)
{
console.log('client is not up');
done(e);
}
else
{
console.log('client is up');
done(null, body);
}
}.bind(this));
}
catch(e)
{
console.log('up check failed: ' + e);
done(e);
}
}
}
module.exports = helper;