mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(mac): isolate build run logs
This commit is contained in:
@@ -5,6 +5,7 @@ cd "$(dirname "$0")/../apps/macos"
|
||||
BUILD_PATH=".build-local"
|
||||
PRODUCT="OpenClaw"
|
||||
BIN="$BUILD_PATH/debug/$PRODUCT"
|
||||
LOG_PATH="${OPENCLAW_MAC_RUN_LOG:-$(mktemp "${TMPDIR:-/tmp}/openclaw-${PRODUCT}.XXXXXX.log")}"
|
||||
|
||||
printf "\n▶️ Building $PRODUCT (debug, build path: $BUILD_PATH)\n"
|
||||
swift build -c debug --product "$PRODUCT" --build-path "$BUILD_PATH"
|
||||
@@ -13,6 +14,6 @@ printf "\n⏹ Stopping existing $PRODUCT...\n"
|
||||
killall -q "$PRODUCT" 2>/dev/null || true
|
||||
|
||||
printf "\n🚀 Launching $BIN ...\n"
|
||||
nohup "$BIN" >/tmp/openclaw.log 2>&1 &
|
||||
nohup "$BIN" >"$LOG_PATH" 2>&1 &
|
||||
PID=$!
|
||||
printf "Started $PRODUCT (PID $PID). Logs: /tmp/openclaw.log\n"
|
||||
printf "Started $PRODUCT (PID $PID). Logs: $LOG_PATH\n"
|
||||
|
||||
17
test/scripts/build-and-run-mac.test.ts
Normal file
17
test/scripts/build-and-run-mac.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const scriptPath = "scripts/build-and-run-mac.sh";
|
||||
|
||||
describe("scripts/build-and-run-mac.sh", () => {
|
||||
it("keeps launch logs isolated unless an explicit log path is provided", () => {
|
||||
const script = readFileSync(scriptPath, "utf8");
|
||||
|
||||
expect(script).toContain(
|
||||
'LOG_PATH="${OPENCLAW_MAC_RUN_LOG:-$(mktemp "${TMPDIR:-/tmp}/openclaw-${PRODUCT}.XXXXXX.log")}"',
|
||||
);
|
||||
expect(script).toContain('nohup "$BIN" >"$LOG_PATH" 2>&1 &');
|
||||
expect(script).toContain('printf "Started $PRODUCT (PID $PID). Logs: $LOG_PATH\\n"');
|
||||
expect(script).not.toContain("/tmp/openclaw.log");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user