aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-01-27 07:42:31 -0500
committerXe Iaso <me@xeiaso.net>2024-01-27 07:42:52 -0500
commit95d775d4d8e6c3d3204ad6360ea29fb6dff53a2c (patch)
treefdbae61742cff14142fd344f45120551befd6112 /scripts
parentb2d1a2eb9b93ddc92938f2a912e01b87b1f65c14 (diff)
downloadxesite-95d775d4d8e6c3d3204ad6360ea29fb6dff53a2c.tar.xz
xesite-95d775d4d8e6c3d3204ad6360ea29fb6dff53a2c.zip
Xeact talk
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/nukestickercache.sh12
-rw-r--r--scripts/prebake-node.mjs56
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);
+ }
+}