A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Record the bench's own pid, not its background subshell's
chimney0cd5cdd44c3c
diff --git a/ds-bot/dev/bench.sh b/ds-bot/dev/bench.shindex 258a7642..ecea0bca 100755--- a/ds-bot/dev/bench.sh+++ b/ds-bot/dev/bench.sh@@ -34,7 +34,9 @@ fialive() { [ -f "$HOME_DIR/$1.pid" ] && kill -0 "-$(cat "$HOME_DIR/$1.pid")" 2>/dev/null; }# Each process runs in its own session (setsid), so its pid is also its process group, which-# outlives it: pnpm exits before the dsh it started. dash's kill takes no `--`.+# outlives it: pnpm exits before the dsh it started. The process writes its own pid: the `$!`+# of a background job is the subshell that runs setsid, not the session leader it forks, so+# it cannot name the group to keep and stop. dash's kill takes no `--`.stop_one() {file="$HOME_DIR/$1.pid"[ -f "$file" ] || return 0@@ -84,15 +86,22 @@ start() {ensure_profilewrite_overlayif ! alive mock; then+ rm -f "$HOME_DIR/mock.pid"(cd "$PLUGIN" && MOCK_PORT="$MOCK_PORT" MOCK_DELAY_MS="${MOCK_DELAY_MS:-300}" MOCK_LOG="$HOME_DIR/mock.jsonl" \- setsid node dev/mock-llm.mjs "$HOME_DIR" </dev/null >"$HOME_DIR/mock.out" 2>&1 & echo $! >"$HOME_DIR/mock.pid")+ exec setsid sh -c 'set -eu; echo $$ >"$1"; shift; exec "$@"' sh "$HOME_DIR/mock.pid" \+ node dev/mock-llm.mjs "$HOME_DIR") </dev/null >"$HOME_DIR/mock.out" 2>&1 &fiif ! alive web; thenlog="$HOME_DIR/web.log"- rm -f "$log"+ rm -f "$log" "$HOME_DIR/web.pid"(cd "$DSH_HARNESS" && DSH_HOME="$HOME_DIR" DEEPSEEK_BASE_URL="http://127.0.0.1:$MOCK_PORT/v1" DEEPSEEK_API_KEY=mock-key \- setsid pnpm -s dsh --profile web --patch apps/web/tests/pin-browse-picker.overlay.yml --patch "$HOME_DIR/bench.patch.yml" \- --no-open --port "$WEB_PORT" </dev/null >"$log" 2>&1 & echo $! >"$HOME_DIR/web.pid")+ exec setsid sh -c 'set -eu; echo $$ >"$1"; shift; exec "$@"' sh "$HOME_DIR/web.pid" \+ pnpm -s dsh --profile web --patch apps/web/tests/pin-browse-picker.overlay.yml --patch "$HOME_DIR/bench.patch.yml" \+ --no-open --port "$WEB_PORT") </dev/null >"$log" 2>&1 &+ # The process writes its own pid just before dsh starts; wait for that file so a+ # start still in progress is not read as an exit.+ i=0+ while [ ! -f "$HOME_DIR/web.pid" ] && [ $i -lt 50 ]; do i=$((i + 1)); sleep 0.1; donei=0until grep -q "dsh web: http" "$log" 2>/dev/null; doi=$((i + 1))