-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcheck-backend.js
More file actions
42 lines (36 loc) · 1.04 KB
/
check-backend.js
File metadata and controls
42 lines (36 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
// 백엔드 서버 상태 체크 스크립트
const https = require('https');
const http = require('http');
const checkEndpoint = (url) => {
return new Promise((resolve, reject) => {
const protocol = url.startsWith('https:') ? https : http;
const req = protocol.get(url, (res) => {
console.log(`${url}: ${res.statusCode}`);
resolve(res.statusCode);
});
req.on('error', (err) => {
console.error(`${url}: ERROR - ${err.message}`);
reject(err);
});
req.setTimeout(5000, () => {
req.destroy();
reject(new Error('Timeout'));
});
});
};
async function checkBackend() {
const endpoints = [
'http://localhost:8080',
'http://localhost:8080/oauth2/authorization/google',
'https://api.woori-zip.lastdance.store',
'https://api.woori-zip.lastdance.store/oauth2/authorization/google'
];
for (const endpoint of endpoints) {
try {
await checkEndpoint(endpoint);
} catch (error) {
console.error(`Failed to check ${endpoint}`);
}
}
}
checkBackend();