新增米家环境监控模块 (采集/聚合/历史/前端 EnvView) + CI 挂载米家凭证目录并自动应用迁移
Docker Build and Push / build-image (push) Successful in 6m54s
Docker Build and Push / build-image (push) Successful in 6m54s
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// 手动跑一次米家采集 (备用): npm run data:mihome
|
||||
// 带文件日志, 便于定位卡点
|
||||
import fs from 'node:fs'
|
||||
|
||||
const LOG = 'D:\\workbench\\iboard\\server\\mihome\\.cache\\cli.log'
|
||||
const log = (m) => fs.appendFileSync(LOG, new Date().toISOString() + ' ' + m + '\n')
|
||||
process.on('uncaughtException', (e) => { log('uncaughtException: ' + (e.stack || e)); process.exit(1) })
|
||||
process.on('unhandledRejection', (e) => { log('unhandledRejection: ' + (e && e.stack ? e.stack : String(e))); process.exit(1) })
|
||||
|
||||
log('start')
|
||||
const m = await import('../server/mihome/index.js')
|
||||
log('imported; calling dailyMaintenance')
|
||||
try {
|
||||
const r = await m.dailyMaintenance()
|
||||
log('done: ' + JSON.stringify(r))
|
||||
console.log('[data:mihome] 完成:', JSON.stringify(r))
|
||||
} catch (e) {
|
||||
if (e instanceof m.MihomeAuthError) {
|
||||
log('auth error: ' + e.message)
|
||||
console.log('[data:mihome] 米家授权不可用: ' + e.message)
|
||||
console.log('[data:mihome] 请运行 npm run data:mihome:login 扫码授权')
|
||||
process.exit(2)
|
||||
}
|
||||
log('failed: ' + (e && e.stack ? e.stack : String(e)))
|
||||
console.error('[data:mihome] 失败:', e.message)
|
||||
process.exit(1)
|
||||
}
|
||||
log('exit(0)')
|
||||
process.exit(0)
|
||||
Reference in New Issue
Block a user