| 12345678910111213141516171819202122232425262728293031323334353637 |
- // P96:修好第 ⑦ 步后重新触发整轮重算,并等待 /api/fleet 恢复 200(最长约 60 分钟)
- const GW = 'http://106.120.102.238:28084'
- const t0 = Date.now()
- const st = () => ((Date.now() - t0) / 1000 / 60).toFixed(1).padStart(5) + 'm'
- const bust = () => 'ts=' + Date.now() + Math.random()
- async function get(path) {
- try {
- const r = await fetch(GW + path + (path.includes('?') ? '&' : '?') + bust(), { headers: { 'Cache-Control': 'no-cache' } })
- const b = await r.text()
- return { status: r.status, len: b.length, txt: b }
- } catch (e) { return { status: 0, len: 0, txt: String(e) } }
- }
- async function post(path, body) {
- const r = await fetch(GW + path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) })
- return { status: r.status, txt: (await r.text()).slice(0, 220) }
- }
- console.log(st() + ' fleet(前) = ' + (await get('/api/fleet')).status)
- console.log(st() + ' 触发 rebuild: ' + JSON.stringify(await post('/ops/api/rebuild', { skip_scada: true, with_verify: false })))
- let ok = false
- for (let i = 0; i < 120; i++) {
- await new Promise((r) => setTimeout(r, 30000))
- const f = await get('/api/fleet')
- const s = await get('/ops/api/state')
- let job = {}
- try { job = JSON.parse(s.txt).job || {} } catch { /* ignore */ }
- const tail = (job.log_tail || []).slice(-1)[0] || ''
- console.log(st() + ' fleet=' + f.status + '(' + f.len + 'B) job=' + (job.status || '?') + ' rc=' + (job.rc ?? '-') + ' · ' + String(tail).trim().slice(0, 100))
- if (f.status === 200 && f.len > 50000) { ok = true; console.log('✅ 数据已恢复 —— 可复跑判据'); break }
- if (job.rc !== null && job.rc !== undefined) {
- console.log('⚠️ 重算结束 rc=' + job.rc)
- for (const l of (job.log_tail || []).slice(-10)) console.log(' ' + String(l).slice(0, 190))
- break
- }
- }
- console.log('END ' + st() + ' ' + (ok ? 'OK' : 'NOT-OK'))
|