diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/nukestickercache.sh | 12 | ||||
| -rw-r--r-- | scripts/prebake-node.mjs | 56 |
2 files changed, 68 insertions, 0 deletions
diff --git a/scripts/nukestickercache.sh b/scripts/nukestickercache.sh new file mode 100755 index 0000000..afe1be0 --- /dev/null +++ b/scripts/nukestickercache.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +XEDNS=$(tailscale status --json | jq '.Peer | to_entries[] | .value.HostName | select(. | test("^xedn-[a-z]{3}$"))' -c -r | sort) +IFS=$'\n' + +jo -a $* + +for xedn in ${XEDNS}; do + curl "http://${xedn}/xedn/purge" --data-binary "$(jo -a $*)" & +done + +wait diff --git a/scripts/prebake-node.mjs b/scripts/prebake-node.mjs new file mode 100644 index 0000000..4a85312 --- /dev/null +++ b/scripts/prebake-node.mjs @@ -0,0 +1,56 @@ +import { execaCommand } from "execa"; + +if (process.argv.length === 2) { + console.error(`usage: node prebake-node.js <path> <video segment count>`); + process.exit(1); +} + +const [_node, _script, basePath, countStr] = process.argv; + +const instances = await (async () => { + try { + const { stdout } = await execaCommand( + "flyctl machines list -a xedn --json --state started | jq [.[].ID]", + { + shell: true, + }, + ); + const instances = JSON.parse(stdout); + return instances; + } catch (error) { + console.error(error); + } +})(); + +for (const i of Array(parseInt(countStr) + 1).keys()) { + try { + const reqs = instances.map((x) => + fetch( + `https://cdn.xeiaso.net/file/christine-static/${basePath}/index${i}.ts`, + { + headers: { + "fly-force-instance": x, + }, + }, + ).then((resp) => { + console.log(`${x}: response get: ${resp.status}`); + return resp; + }) + ); + + const resps = await Promise.all(reqs); + resps.forEach(async (resp) => { + if (resp.status !== 200) { + console.error( + `failure: ${resp.url}: request ID: ${ + resp.headers["fly-request-id"] + }, body: ${await resp.text()}`, + ); + } + + console.log(`ok: ${resp.headers["fly-request-id"]}`); + }); + } catch (e) { + console.error(e); + } +} |
