This commit is contained in:
zk
2026-05-18 23:45:04 +01:00
parent c07dd5c878
commit e2d28f8ac3
2 changed files with 21 additions and 9 deletions
+1 -7
View File
@@ -1,10 +1,5 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
# MYT gRPC probe — run inside the tachi-server container.
#
# kubectl exec -it deploy/tachi-server -- sh /app/docker/myt-grpc-probe.sh \
# --access-code "YOUR_ACCESS_CODE" --game chunithm
#
# Or paste the block from the bottom of this file if the script is not on the image yet.
set -euo pipefail
@@ -12,7 +7,6 @@ TACHI_ROOT="${TACHI_ROOT:-/app}"
cd "${TACHI_ROOT}/typescript/server"
exec bun run src/scripts/myt-grpc-probe.ts -- "$@"
# --- paste into `kubectl exec ... -- sh` if this file is not on the image yet ---
# set -euo pipefail
# cd /app/typescript/server
# bun run src/scripts/myt-grpc-probe.ts -- --access-code "YOUR_ACCESS_CODE" --game chunithm
@@ -133,17 +133,23 @@ async function probeLookup(
}
}
function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function probeGetPlaylog(
transport: Transport,
profileApiId: string,
game: ProbeGame,
maxItems: number,
pauseMs: number,
): Promise<number> {
const started = performance.now();
let count = 0;
let firstItemMs: number | undefined;
log("stream", `GetPlaylog (max ${maxItems} items) profileApiId=${profileApiId} ...`);
const pauseNote = pauseMs > 0 ? `, pause ${pauseMs}ms/item (import-like)` : "";
log("stream", `GetPlaylog (max ${maxItems} items${pauseNote}) profileApiId=${profileApiId} ...`);
const stream = createPlaylogStream(transport, profileApiId, game);
@@ -155,6 +161,10 @@ async function probeGetPlaylog(
log("stream", `First item after ${firstItemMs}ms`, { sample: summarizeItem(item) });
}
if (pauseMs > 0) {
await sleep(pauseMs);
}
if (count >= maxItems) {
log("stream", `Stopping after ${count} item(s) (--max-items)`);
break;
@@ -253,6 +263,7 @@ myt-grpc-probe — test MYT unary Lookup vs streaming GetPlaylog
--access-code <code> Card access code (runs Lookup first)
--game <name> chunithm | maimaidx | ongeki | wacca (default: chunithm)
--max-items <n> Stop stream after N items (default: 5)
--pause-ms <n> Sleep after each item (simulate slow score import)
--lookup-only Skip GetPlaylog
--stream-only Skip Lookup (requires --profile-api-id)
-h, --help
@@ -262,6 +273,7 @@ Examples (inside container):
cd /app/typescript/server
bun run src/scripts/myt-grpc-probe.ts -- --access-code "YOUR_CODE" --game chunithm
bun run src/scripts/myt-grpc-probe.ts -- --profile-api-id "abc123" --max-items 1
bun run src/scripts/myt-grpc-probe.ts -- --profile-api-id "abc123" --max-items 500 --pause-ms 50
`);
}
@@ -272,6 +284,7 @@ async function main(): Promise<void> {
"access-code": { type: "string" },
game: { type: "string", default: "chunithm" },
"max-items": { type: "string", default: "5" },
"pause-ms": { type: "string", default: "0" },
"lookup-only": { type: "boolean", default: false },
"stream-only": { type: "boolean", default: false },
help: { type: "boolean", short: "h", default: false },
@@ -294,6 +307,11 @@ async function main(): Promise<void> {
fail("--max-items must be a positive integer");
}
const pauseMs = Number.parseInt(values["pause-ms"] ?? "0", 10);
if (!Number.isFinite(pauseMs) || pauseMs < 0) {
fail("--pause-ms must be a non-negative integer");
}
printRuntimeInfo();
const transport = createTransport();
@@ -318,7 +336,7 @@ async function main(): Promise<void> {
fail("Need --profile-api-id or --access-code for GetPlaylog");
}
await probeGetPlaylog(transport, profileApiId, game, maxItems);
await probeGetPlaylog(transport, profileApiId, game, maxItems, pauseMs);
log("done", "All phases OK — exit 0");
}