forked from ioBroker/ioBroker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
39 lines (35 loc) · 1.05 KB
/
test.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
const http = require('node:http');
function checkAdmin() {
return new Promise(resolve => http.get('http://localhost:8081')
.on('response', response => {
let body = '';
response.on('data', chunk => body += chunk.toString('utf8'));
response.on('end', () => {
if (body.includes('<title>Admin</title>')) {
console.log('ioBroker admin is running');
resolve(true);
} else {
console.error('ioBroker admin is NOT running');
resolve(false);
}
});
})
.on('error', () => {
console.log('Cannot reach localhost:8081');
resolve(false);
}));
}
function wait() {
return new Promise(resolve => setTimeout(() => resolve(), 5000));
}
async function test() {
for (let i = 0; i < 10; i++) {
let result = await checkAdmin();
if (result) {
process.exit(0);
}
await wait();
}
process.exit(1);
}
test();