| 1234567891011121314151617181920212223 |
- // P92-6:破缓存读取 /ops/api/state 与 /api/fleet(带 ?ts= 与 no-cache 头)
- const GW = 'http://106.120.102.238:28084'
- const ts = Date.now()
- async function get(path, json) {
- const r = await fetch(GW + path + (path.includes('?') ? '&' : '?') + 'ts=' + ts, {
- headers: { 'Cache-Control': 'no-cache', Pragma: 'no-cache' },
- })
- const b = await r.text()
- console.log(path + ' -> ' + r.status + ' ' + b.length + ' B')
- if (json) { try { return JSON.parse(b) } catch { return null } }
- return b
- }
- const j = await get('/ops/api/state', true)
- if (j) {
- console.log(' now=' + j.now + ' · job.status=' + (j.job || {}).status + ' · rc=' + (j.job || {}).rc + ' · seconds=' + (j.job || {}).seconds)
- const tail = (j.job || {}).log_tail || []
- console.log(' 日志尾部:')
- for (const l of tail.slice(-6)) console.log(' ' + String(l).slice(0, 180))
- console.log(' products=' + JSON.stringify(j.products).slice(0, 200))
- console.log(' anchors=' + JSON.stringify(j.anchors))
- }
- const f = await get('/api/fleet', false)
- if (typeof f === 'string') console.log(' fleet 前 160 字: ' + f.slice(0, 160))
|