-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutility.js
47 lines (42 loc) · 1.04 KB
/
utility.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
43
44
45
46
47
const axios = require('axios')
async function checkStatusPromise(django_ip){
return await axios.get(`http://${django_ip}:8000/api/status`)
.then(api_response => {
if(api_response.status == 200 && api_response.data.status == 'OK'){
return true
} else {
return false
}
})
.catch(error => {
return false
})
}
function checkStatusLog(django_ip){
let url = `http://${django_ip}:8000/api/status`
axios.get(url)
.then(api_response => {
if(api_response.status == 200 && api_response.data.status == 'OK'){
console.log(`Backend Django service up and running on port ${8000}!`)
}
})
.catch(error => {
console.log(`Seems Backend services are down...`)
})
}
function checkStatusReturn(django_ip){
axios.get(`http://${django_ip}:8000/api/status`)
.then(api_response => {
if(api_response.status == 200 && api_response.data.status == 'OK'){
return false
}
})
.catch(error => {
return true
})
}
module.exports = {
checkStatusPromise: checkStatusPromise,
checkStatusLog: checkStatusLog,
checkStatusReturn: checkStatusReturn
}