The code and data behind xeiaso.net
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 56 lines 1.4 kB view raw
1import { execaCommand } from "execa"; 2 3if (process.argv.length === 2) { 4 console.error(`usage: node prebake-node.js <path> <video segment count>`); 5 process.exit(1); 6} 7 8const [_node, _script, basePath, countStr] = process.argv; 9 10const instances = await (async () => { 11 try { 12 const { stdout } = await execaCommand( 13 "flyctl machines list -a xedn --json --state started | jq [.[].ID]", 14 { 15 shell: true, 16 }, 17 ); 18 const instances = JSON.parse(stdout); 19 return instances; 20 } catch (error) { 21 console.error(error); 22 } 23})(); 24 25for (const i of Array(parseInt(countStr) + 1).keys()) { 26 try { 27 const reqs = instances.map((x) => 28 fetch( 29 `https://cdn.xeiaso.net/file/christine-static/${basePath}/index${i}.ts`, 30 { 31 headers: { 32 "fly-force-instance": x, 33 }, 34 }, 35 ).then((resp) => { 36 console.log(`${x}: response get: ${resp.status}`); 37 return resp; 38 }) 39 ); 40 41 const resps = await Promise.all(reqs); 42 resps.forEach(async (resp) => { 43 if (resp.status !== 200) { 44 console.error( 45 `failure: ${resp.url}: request ID: ${ 46 resp.headers["fly-request-id"] 47 }, body: ${await resp.text()}`, 48 ); 49 } 50 51 console.log(`ok: ${resp.headers["fly-request-id"]}`); 52 }); 53 } catch (e) { 54 console.error(e); 55 } 56}