@things-factory/weather 9.0.24 → 9.0.34
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/client/ol-components/wind-data-tile-layer.ts +1 -1
- package/client/ol-components/wind-rasterized-layer.ts +1 -1
- package/dist-client/ol-components/wind-data-tile-layer.js +1 -1
- package/dist-client/ol-components/wind-data-tile-layer.js.map +1 -1
- package/dist-client/ol-components/wind-rasterized-layer.js +1 -1
- package/dist-client/ol-components/wind-rasterized-layer.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/services/headless-pool.d.ts +10 -1
- package/dist-server/services/headless-pool.js +25 -79
- package/dist-server/services/headless-pool.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -7
- package/server/services/headless-pool.ts +27 -90
|
@@ -1,89 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Weather Service Headless Pool
|
|
4
|
+
* Using the unified headless pool system from @things-factory/shell
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.getBrowserPool = getBrowserPool;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
// Create the weather pool instance
|
|
10
|
+
const weatherPool = (0, shell_1.getOrCreateHeadlessPool)('weather', {
|
|
11
|
+
min: 1,
|
|
12
|
+
max: 5,
|
|
13
|
+
headless: 'new', // Keep 'new' for weather compatibility
|
|
14
|
+
args: [
|
|
15
|
+
...shell_1.HEADLESS_POOL_ARGUMENT_SETS.basic,
|
|
16
|
+
...shell_1.HEADLESS_POOL_ARGUMENT_SETS.keychain_safe,
|
|
17
|
+
...shell_1.HEADLESS_POOL_ARGUMENT_SETS.security_enhanced
|
|
18
|
+
],
|
|
19
|
+
acquireTimeoutMillis: 10000,
|
|
20
|
+
idleTimeoutMillis: 30000, // 30초 후 유휴 인스턴스 제거
|
|
21
|
+
testOnBorrow: true,
|
|
22
|
+
enableCleanup: true
|
|
23
|
+
});
|
|
17
24
|
/**
|
|
18
25
|
* 헤드리스 브라우저 풀 가져오기 (싱글톤 패턴)
|
|
19
26
|
*/
|
|
20
27
|
function getBrowserPool() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return initializeChromium();
|
|
27
|
-
},
|
|
28
|
-
// 브라우저 인스턴스 유효성 검사
|
|
29
|
-
validate(browser) {
|
|
30
|
-
return Promise.race([
|
|
31
|
-
new Promise(res => setTimeout(() => res(false), 1500)),
|
|
32
|
-
browser
|
|
33
|
-
.version()
|
|
34
|
-
.then(_ => true)
|
|
35
|
-
.catch(_ => false)
|
|
36
|
-
]);
|
|
37
|
-
},
|
|
38
|
-
// 브라우저 인스턴스 파괴
|
|
39
|
-
destroy(browser) {
|
|
40
|
-
return browser.close();
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
// 풀 설정
|
|
44
|
-
min: 1, // 최소 인스턴스 수
|
|
45
|
-
max: 5, // 최대 인스턴스 수
|
|
46
|
-
testOnBorrow: true,
|
|
47
|
-
acquireTimeoutMillis: 10000,
|
|
48
|
-
idleTimeoutMillis: 30000 // 30초 후 유휴 인스턴스 제거
|
|
49
|
-
});
|
|
50
|
-
// 애플리케이션 종료 시 정리
|
|
51
|
-
process.on('exit', async () => {
|
|
52
|
-
if (browserPool) {
|
|
53
|
-
await browserPool.drain();
|
|
54
|
-
await browserPool.clear();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return browserPool;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Chromium 초기화
|
|
62
|
-
*/
|
|
63
|
-
async function initializeChromium() {
|
|
64
|
-
// puppeteer가 없으면 오류
|
|
65
|
-
if (!puppeteer) {
|
|
66
|
-
throw new Error('Puppeteer is not available');
|
|
67
|
-
}
|
|
68
|
-
// 크로미움 경로 (환경설정에서 가져옴)
|
|
69
|
-
const CHROMIUM_PATH = env_1.config.get('CHROMIUM_PATH');
|
|
70
|
-
// 실행 설정
|
|
71
|
-
const launchSettings = {
|
|
72
|
-
args: ['--hide-scrollbars', '--mute-audio', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'],
|
|
73
|
-
headless: 'new' // 'new' = 최신 헤드리스 모드
|
|
28
|
+
return {
|
|
29
|
+
acquire: () => weatherPool.acquire(),
|
|
30
|
+
release: (resource) => weatherPool.release(resource),
|
|
31
|
+
drain: () => weatherPool.cleanup(),
|
|
32
|
+
clear: () => weatherPool.reset()
|
|
74
33
|
};
|
|
75
|
-
// 크로미움 경로가 설정되어 있으면 사용
|
|
76
|
-
if (CHROMIUM_PATH) {
|
|
77
|
-
launchSettings['executablePath'] = CHROMIUM_PATH;
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
// 브라우저 실행
|
|
81
|
-
const browser = await puppeteer.launch(launchSettings);
|
|
82
|
-
return browser;
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
console.error('크로미움 초기화 실패:', err);
|
|
86
|
-
throw err;
|
|
87
|
-
}
|
|
88
34
|
}
|
|
89
35
|
//# sourceMappingURL=headless-pool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless-pool.js","sourceRoot":"","sources":["../../server/services/headless-pool.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"headless-pool.js","sourceRoot":"","sources":["../../server/services/headless-pool.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAuBH,wCAOC;AA5BD,iDAA6G;AAE7G,mCAAmC;AACnC,MAAM,WAAW,GAAG,IAAA,+BAAuB,EAAC,SAAS,EAAE;IACrD,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,QAAQ,EAAE,KAAK,EAAE,uCAAuC;IACxD,IAAI,EAAE;QACJ,GAAG,mCAA2B,CAAC,KAAK;QACpC,GAAG,mCAA2B,CAAC,aAAa;QAC5C,GAAG,mCAA2B,CAAC,iBAAiB;KACjD;IACD,oBAAoB,EAAE,KAAK;IAC3B,iBAAiB,EAAE,KAAK,EAAE,mBAAmB;IAC7C,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,IAAI;CACpB,CAAC,CAAA;AAEF;;GAEG;AACH,SAAgB,cAAc;IAC5B,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE;QACpC,OAAO,EAAE,CAAC,QAAa,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzD,KAAK,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE;QAClC,KAAK,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE;KACjC,CAAA;AACH,CAAC","sourcesContent":["/**\n * Weather Service Headless Pool\n * Using the unified headless pool system from @things-factory/shell\n */\n\nimport { getOrCreateHeadlessPool, getAllPoolStats, HEADLESS_POOL_ARGUMENT_SETS } from '@things-factory/shell'\n\n// Create the weather pool instance\nconst weatherPool = getOrCreateHeadlessPool('weather', {\n min: 1,\n max: 5,\n headless: 'new', // Keep 'new' for weather compatibility\n args: [\n ...HEADLESS_POOL_ARGUMENT_SETS.basic,\n ...HEADLESS_POOL_ARGUMENT_SETS.keychain_safe,\n ...HEADLESS_POOL_ARGUMENT_SETS.security_enhanced\n ],\n acquireTimeoutMillis: 10000,\n idleTimeoutMillis: 30000, // 30초 후 유휴 인스턴스 제거\n testOnBorrow: true,\n enableCleanup: true\n})\n\n/**\n * 헤드리스 브라우저 풀 가져오기 (싱글톤 패턴)\n */\nexport function getBrowserPool() {\n return {\n acquire: () => weatherPool.acquire(),\n release: (resource: any) => weatherPool.release(resource),\n drain: () => weatherPool.cleanup(),\n clear: () => weatherPool.reset()\n }\n}"]}
|