fix(@projects/magic-civilization): 🐛 add godot process check for batch status
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
aa7adad8e9
commit
60838c293f
1 changed files with 11 additions and 2 deletions
|
|
@ -263,18 +263,27 @@ if [[ "${MODE}" == "status" ]]; then
|
||||||
QUERY_STAMP="${1:?usage: apricot-run.sh status <stamp>}"
|
QUERY_STAMP="${1:?usage: apricot-run.sh status <stamp>}"
|
||||||
UNIT="mc-batch-${QUERY_STAMP}"
|
UNIT="mc-batch-${QUERY_STAMP}"
|
||||||
|
|
||||||
# Single ssh probe with short ConnectTimeout. Three lightweight queries:
|
# Single ssh probe with short ConnectTimeout. Four lightweight queries:
|
||||||
# 1. systemctl --user is-active <unit> (active|inactive|failed|unknown)
|
# 1. systemctl --user is-active <unit> (active|inactive|failed|unknown)
|
||||||
# 2. count of completion.marker files under <stamp>/*/
|
# 2. count of completion.marker files under <stamp>/*/
|
||||||
# 3. count of turn_stats.jsonl files under <stamp>/*/game_*/
|
# 3. count of turn_stats.jsonl files under <stamp>/*/game_*/
|
||||||
|
# 4. count of live godot processes for THIS batch stamp
|
||||||
# We also read seeds_total from the first submode dir if present.
|
# We also read seeds_total from the first submode dir if present.
|
||||||
|
#
|
||||||
|
# The godot-proc count is load-bearing: `flatpak run` detaches into a
|
||||||
|
# systemd user scope, so autoplay-batch.sh's `wait` returns and
|
||||||
|
# completion.marker is touched while the actual godot processes are still
|
||||||
|
# running headless games. Without checking live procs, fetch would pull
|
||||||
|
# mid-run turn_stats with outcome=in_progress and the consumer would
|
||||||
|
# think the gate failed when in fact games hadn't finished yet.
|
||||||
PROBE='set +e
|
PROBE='set +e
|
||||||
IS_ACTIVE=$(systemctl --user is-active '"${UNIT}"' 2>/dev/null || echo unknown)
|
IS_ACTIVE=$(systemctl --user is-active '"${UNIT}"' 2>/dev/null || echo unknown)
|
||||||
MARKER_COUNT=$(ls "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/completion.marker 2>/dev/null | wc -l | tr -d " ")
|
MARKER_COUNT=$(ls "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/completion.marker 2>/dev/null | wc -l | tr -d " ")
|
||||||
STATS_COUNT=$(ls "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/game_*/turn_stats.jsonl 2>/dev/null | wc -l | tr -d " ")
|
STATS_COUNT=$(ls "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/game_*/turn_stats.jsonl 2>/dev/null | wc -l | tr -d " ")
|
||||||
|
GODOT_PROCS=$(pgrep -af "godot.*'"${QUERY_STAMP}"'" 2>/dev/null | grep -c "godot --path" || echo 0)
|
||||||
SEEDS_TOTAL=$(cat "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/seeds_total 2>/dev/null | head -1)
|
SEEDS_TOTAL=$(cat "$HOME/.cache/mc-batches/'"${QUERY_STAMP}"'"/*/seeds_total 2>/dev/null | head -1)
|
||||||
SEEDS_TOTAL=${SEEDS_TOTAL:-0}
|
SEEDS_TOTAL=${SEEDS_TOTAL:-0}
|
||||||
printf "%s|%s|%s|%s\n" "$IS_ACTIVE" "$MARKER_COUNT" "$STATS_COUNT" "$SEEDS_TOTAL"'
|
printf "%s|%s|%s|%s|%s\n" "$IS_ACTIVE" "$MARKER_COUNT" "$STATS_COUNT" "$SEEDS_TOTAL" "$GODOT_PROCS"'
|
||||||
|
|
||||||
PROBE_OUT="$(ssh -o ConnectTimeout=5 -o BatchMode=yes "${APRICOT}" "${PROBE}" 2>/dev/null)" || PROBE_OUT=""
|
PROBE_OUT="$(ssh -o ConnectTimeout=5 -o BatchMode=yes "${APRICOT}" "${PROBE}" 2>/dev/null)" || PROBE_OUT=""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue