Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

raea cloud's box sends each agent's stderr along its socket (_raea/stderr), so the run's trace keeps it instead of only the box's disk; box.sh up won't rebuild a box whose server can't say whether agents are running (11-25, Shane: "make sure for cloud runs we are getting all the session traces and logs ... all recoverable")

shinyobjectz7611a96e346c
diff --git a/sdk/cloud/deploy/sprites/box.sh b/sdk/cloud/deploy/sprites/box.sh
index 90e95951..5a03be0b 100755
--- a/sdk/cloud/deploy/sprites/box.sh
+++ b/sdk/cloud/deploy/sprites/box.sh
@@ -79,9 +79,11 @@ up)
if [ "${RAEA_BOX_FORCE:-}" != 1 ]; then
for i in $(seq 1 90); do
n=$(x ". ~/.raea-cloud.env 2>/dev/null; curl -fsS -m 5 -H \"authorization: Bearer \$RAEA_CLOUD_TOKEN\" localhost:8080/v1/health 2>/dev/null" | python3 -c 'import json,sys
-try: print(json.load(sys.stdin).get("running", 0))
-except Exception: print(0)')
- [ "${n:-0}" = 0 ] && break
+try: print(json.load(sys.stdin).get("running", "unknown"))
+except Exception: print("down")')
+ # down: nothing to cut off; unknown: a server too old to say, so it isn't rebuilt blind
+ [ "$n" = 0 ] || [ "$n" = down ] && break
+ [ "$n" = unknown ] && { echo "box: $NAME's server doesn't say whether agents are running: rebuild it when it's idle (RAEA_BOX_FORCE=1)"; exit 1; }
[ "$i" = 90 ] && { echo "box: $NAME still has $n agents running: not rebuilt (RAEA_BOX_FORCE=1 to cut them off)"; exit 1; }
[ "$i" = 1 ] && echo "box: $NAME has $n agents running: waiting for them to finish"
sleep 10
diff --git a/sdk/cloud/server/main.ts b/sdk/cloud/server/main.ts
index 2292db48..b1df13f6 100644
--- a/sdk/cloud/server/main.ts
+++ b/sdk/cloud/server/main.ts
@@ -347,9 +347,15 @@ server.on("upgrade", (req, socket, head) => {
}
const env = own ? { ...withoutKeys(childEnv()), ...agent.env, ...RUN_DEFAULTS, ...own } : { ...childEnv(), ...agent.env }
wss.handleUpgrade(req, socket, head, (ws) => {
- const child = spawn(agent.command, agent.args, { cwd: WORK, env, stdio: ["pipe", "pipe", "inherit"] })
+ const child = spawn(agent.command, agent.args, { cwd: WORK, env, stdio: ["pipe", "pipe", "pipe"] })
running.add(child)
child.on("exit", () => running.delete(child))
+ // its stderr to the box's log as before, and along the socket as _raea/stderr notifications, so raea cloud keeps
+ // it with the run's trace (runtrace.ts) instead of only on this box's disk (11-25: raea-1's logs died with it)
+ child.stderr.setEncoding("utf8").on("data", (c: string) => {
+ process.stderr.write(c)
+ if (ws.readyState === ws.OPEN) ws.send(JSON.stringify({ jsonrpc: "2.0", method: "_raea/stderr", params: { text: c.slice(0, 16_000) } }))
+ })
let buf = ""
// ACP messages are newline-delimited JSON: split on \n only
child.stdout.setEncoding("utf8").on("data", (c: string) => {