-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathstatus.js
More file actions
123 lines (90 loc) · 3.62 KB
/
status.js
File metadata and controls
123 lines (90 loc) · 3.62 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Meteor.methods({
'statusCheck' : function () {
function checkApinf () {
// initial status object
var status = {
operational : false,
message : ""
};
try{
// initial host for apinf
var apinfHost = Meteor.settings.apinf.host;
// response object from apinf GET request
var apinfResponse = Meteor.http.call("GET", apinfHost);
// checks is the status code matches 200
if (apinfResponse.statusCode == 200) {
// if status code is 200 changes operational state to TRUE and provides success message
status.operational = true;
status.message = "Apinf is operating normally.";
}else{
// if not, operational state remains false and provides different message
status.message = "Apinf is down for some reason. Please contact support.";
}
}catch(e){
// if http call crashes, sending different message
status.message = "Not able to access Apinf.";
}
return status;
}
function checkApiUmbrella () {
// initial status object
var status = {
operational : false,
message : ""
};
try{
// initial host for API umbrella
var apiUmbrellaHost = Meteor.settings.apiUmbrella.host;
// response object from API Umbrella GET request
var apiUmbrellaResponse = Meteor.http.call("GET", apiUmbrellaHost);
// checks is the status code matches 200
if (apiUmbrellaResponse.statusCode == 200) {
// if status code is 200 changes operational state to TRUE and provides success message
status.operational = true;
status.message = "API Umbrella is operating normally.";
}else{
// if not, operational state remains false and provides different message
status.message = "API Umbrella is down for some reason. Please contact support.";
}
}catch(e){
// if http call crashes, sending different message
status.message = "Not able to reach API Umbrella.";
}
// if not, operational state remains false and provides different message
return status;
}
function checkES () {
// initial status object
var status = {
operational : false,
message : ""
};
try{
// initial host for elasticsearch instance
var elasticsearchInstance = Meteor.settings.elasticsearch.host;
// response object from elasticsearch GET request
var elasticsearchResponse = Meteor.http.call("GET", elasticsearchInstance);
// checks is the status code matches 200
if (elasticsearchResponse.statusCode == 200) {
// if status code is 200 changes operational state to TRUE and provides success message
status.operational = true;
status.message = "Elasticsearch is operating normally.";
}else{
// if not, operational state remains false and provides different message
status.message = "Elasticsearch is down for some reason. Please contact support.";
}
}catch(e){
// if http call crashes, sending different message
status.message = "Not able to reach Elasticsearch.";
}
// if not, operational state remains false and provides different message
return status;
}
// statusCheck method returns object with statuses of all of the status checking functions written above
return {
apinf : checkApinf(),
elasticsearch : checkES(),
apiUmbrella : checkApiUmbrella()
}
}
});