@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/weather",
3
- "version": "9.0.24",
3
+ "version": "9.0.34",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -31,16 +31,15 @@
31
31
  "@mapbox/mbtiles": "^0.12.1",
32
32
  "@operato/graphql": "^9.0.0",
33
33
  "@operato/shell": "^9.0.0",
34
- "@things-factory/auth-base": "^9.0.24",
35
- "@things-factory/cache-service": "^9.0.24",
34
+ "@things-factory/auth-base": "^9.0.34",
35
+ "@things-factory/cache-service": "^9.0.34",
36
36
  "@things-factory/env": "^9.0.20",
37
- "@things-factory/shell": "^9.0.24",
37
+ "@things-factory/shell": "^9.0.34",
38
38
  "colormap": "^2.3.2",
39
- "ol": "^10.4.0",
40
- "puppeteer": "^24.5.0"
39
+ "ol": "^10.4.0"
41
40
  },
42
41
  "devDependencies": {
43
42
  "@types/colormap": "^2.3.4"
44
43
  },
45
- "gitHead": "5b0961255631f7b6bb0c83e66d3d8021e15658bd"
44
+ "gitHead": "b85ff377bc6ca4a81e53342b20087d4e0a286772"
46
45
  }
@@ -1,97 +1,34 @@
1
- import * as genericPool from 'generic-pool'
2
- import { config } from '@things-factory/env'
3
-
4
- // puppeteer 모듈 동적 로드 (에러 처리 포함)
5
- let puppeteer
6
- try {
7
- puppeteer = require('puppeteer')
8
- } catch (err) {
9
- console.error('Puppeteer 로드 실패:', err)
10
- }
11
-
12
- // 브라우저 풀 인스턴스
13
- let browserPool
14
-
15
1
  /**
16
- * 헤드리스 브라우저 풀 가져오기 (싱글톤 패턴)
2
+ * Weather Service Headless Pool
3
+ * Using the unified headless pool system from @things-factory/shell
17
4
  */
18
- export function getBrowserPool() {
19
- if (!browserPool) {
20
- browserPool = genericPool.createPool(
21
- {
22
- // 브라우저 인스턴스 생성
23
- create() {
24
- console.log('날씨 서비스용 headless 브라우저 인스턴스 생성')
25
- return initializeChromium()
26
- },
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
- // 브라우저 인스턴스 파괴
40
- destroy(browser) {
41
- return browser.close()
42
- }
43
- },
44
- {
45
- // 풀 설정
46
- min: 1, // 최소 인스턴스 수
47
- max: 5, // 최대 인스턴스 수
48
- testOnBorrow: true,
49
- acquireTimeoutMillis: 10000,
50
- idleTimeoutMillis: 30000 // 30초 후 유휴 인스턴스 제거
51
- }
52
- )
53
-
54
- // 애플리케이션 종료 시 정리
55
- process.on('exit', async () => {
56
- if (browserPool) {
57
- await browserPool.drain()
58
- await browserPool.clear()
59
- }
60
- })
61
- }
62
5
 
63
- return browserPool
64
- }
6
+ import { getOrCreateHeadlessPool, getAllPoolStats, HEADLESS_POOL_ARGUMENT_SETS } from '@things-factory/shell'
7
+
8
+ // Create the weather pool instance
9
+ const weatherPool = getOrCreateHeadlessPool('weather', {
10
+ min: 1,
11
+ max: 5,
12
+ headless: 'new', // Keep 'new' for weather compatibility
13
+ args: [
14
+ ...HEADLESS_POOL_ARGUMENT_SETS.basic,
15
+ ...HEADLESS_POOL_ARGUMENT_SETS.keychain_safe,
16
+ ...HEADLESS_POOL_ARGUMENT_SETS.security_enhanced
17
+ ],
18
+ acquireTimeoutMillis: 10000,
19
+ idleTimeoutMillis: 30000, // 30초 후 유휴 인스턴스 제거
20
+ testOnBorrow: true,
21
+ enableCleanup: true
22
+ })
65
23
 
66
24
  /**
67
- * Chromium 초기화
25
+ * 헤드리스 브라우저 풀 가져오기 (싱글톤 패턴)
68
26
  */
69
- async function initializeChromium() {
70
- // puppeteer가 없으면 오류
71
- if (!puppeteer) {
72
- throw new Error('Puppeteer is not available')
73
- }
74
-
75
- // 크로미움 경로 (환경설정에서 가져옴)
76
- const CHROMIUM_PATH = config.get('CHROMIUM_PATH')
77
-
78
- // 실행 설정
79
- const launchSettings = {
80
- args: ['--hide-scrollbars', '--mute-audio', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'],
81
- headless: 'new' // 'new' = 최신 헤드리스 모드
82
- }
83
-
84
- // 크로미움 경로가 설정되어 있으면 사용
85
- if (CHROMIUM_PATH) {
86
- launchSettings['executablePath'] = CHROMIUM_PATH
87
- }
88
-
89
- try {
90
- // 브라우저 실행
91
- const browser = await puppeteer.launch(launchSettings)
92
- return browser
93
- } catch (err) {
94
- console.error('크로미움 초기화 실패:', err)
95
- throw err
27
+ export function getBrowserPool() {
28
+ return {
29
+ acquire: () => weatherPool.acquire(),
30
+ release: (resource: any) => weatherPool.release(resource),
31
+ drain: () => weatherPool.cleanup(),
32
+ clear: () => weatherPool.reset()
96
33
  }
97
- }
34
+ }