logmon-cli 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +45 -12
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -7,9 +7,37 @@ const os = require('os');
|
|
|
7
7
|
const readline = require('readline');
|
|
8
8
|
const pkg = require('./package.json');
|
|
9
9
|
|
|
10
|
+
const http = require('http');
|
|
11
|
+
|
|
10
12
|
// 전체 인자 중 'uninstall'이 포함되어 있는지 견고하게 확인
|
|
11
13
|
const isUninstall = process.argv.includes('uninstall');
|
|
12
14
|
|
|
15
|
+
function checkBackendHealth(url) {
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const matches = url.match(/https?:\/\/([^:/]+)(?::(\d+))?/);
|
|
18
|
+
if (!matches) {
|
|
19
|
+
resolve(false);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const host = matches[1];
|
|
23
|
+
const port = matches[2] || 80;
|
|
24
|
+
const path = '/api/health';
|
|
25
|
+
|
|
26
|
+
const req = http.get({ host, port, path, timeout: 500 }, (res) => {
|
|
27
|
+
resolve(res.statusCode === 200);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
req.on('error', () => {
|
|
31
|
+
resolve(false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
req.on('timeout', () => {
|
|
35
|
+
req.destroy();
|
|
36
|
+
resolve(false);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
13
41
|
function getSavedConfig() {
|
|
14
42
|
const homeDir = os.homedir();
|
|
15
43
|
const unixConfigPath = path.join(homeDir, '.logmon_agent', 'logmon_config.json');
|
|
@@ -40,6 +68,13 @@ function askQuestion(query) {
|
|
|
40
68
|
}
|
|
41
69
|
|
|
42
70
|
async function run() {
|
|
71
|
+
// 버전 확인 파라미터 체크
|
|
72
|
+
const isVersion = process.argv.includes('--version') || process.argv.includes('-v') || process.argv.includes('version');
|
|
73
|
+
if (isVersion) {
|
|
74
|
+
console.log(`logmon v${pkg.version}`);
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
|
|
43
78
|
let apiKey = "default_dev_key";
|
|
44
79
|
let backendUrl = "http://localhost:3008/api/logmon";
|
|
45
80
|
|
|
@@ -65,18 +100,16 @@ async function run() {
|
|
|
65
100
|
}
|
|
66
101
|
backendUrl = foundUrl || process.env.BACKEND_URL || backendUrl;
|
|
67
102
|
|
|
68
|
-
//
|
|
69
|
-
if (!
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (inputKey.trim()) {
|
|
79
|
-
apiKey = inputKey.trim();
|
|
103
|
+
// 자동 감지(Auto-detect) 및 덮어쓰기 로직 (유저 타이핑 완전 제거)
|
|
104
|
+
if (!foundUrl && !process.env.BACKEND_URL && process.env.LOGMON_TEST_MODE !== 'true') {
|
|
105
|
+
const is3008Healthy = await checkBackendHealth("http://localhost:3008");
|
|
106
|
+
if (is3008Healthy) {
|
|
107
|
+
backendUrl = "http://localhost:3008/api/logmon";
|
|
108
|
+
} else {
|
|
109
|
+
const is8000Healthy = await checkBackendHealth("http://localhost:8000");
|
|
110
|
+
if (is8000Healthy) {
|
|
111
|
+
backendUrl = "http://localhost:8000/api/logmon";
|
|
112
|
+
}
|
|
80
113
|
}
|
|
81
114
|
}
|
|
82
115
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "logmon-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "LogMon Agent Auto Installer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"logmon-cli": "index.js"
|
|
7
|
+
"logmon-cli": "index.js",
|
|
8
|
+
"logmon": "index.js"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"index.js"
|