Skip to content

Commit 925c71d

Browse files
authored
ops: harden varlock startup and broker status detection (#106)
1 parent 47cecc9 commit 925c71d

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

bin/baudbot

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,27 +369,31 @@ print_broker_connection_status() {
369369
local health_summary=""
370370
local connection_state=""
371371
local components_line=""
372+
local bridge_running=0
372373

373374
if ! broker_mode_configured "$agent_user"; then
374375
echo -e "${BOLD}broker connection:${RESET} not configured"
375376
return 0
376377
fi
377378

378379
if [ "$(id -u)" -eq 0 ]; then
379-
sudo -u "$agent_user" tmux has-session -t slack-bridge 2>/dev/null || {
380-
echo -e "${BOLD}broker connection:${RESET} disconnected (bridge tmux session not running)"
381-
return 0
382-
}
380+
if pgrep -u "$agent_user" -f "node broker-bridge.mjs" >/dev/null 2>&1; then
381+
bridge_running=1
382+
fi
383383
elif [ "$(id -un)" = "$agent_user" ]; then
384-
tmux has-session -t slack-bridge 2>/dev/null || {
385-
echo -e "${BOLD}broker connection:${RESET} disconnected (bridge tmux session not running)"
386-
return 0
387-
}
384+
if pgrep -u "$agent_user" -f "node broker-bridge.mjs" >/dev/null 2>&1; then
385+
bridge_running=1
386+
fi
388387
else
389388
echo -e "${BOLD}broker connection:${RESET} configured (run with sudo for runtime status)"
390389
return 0
391390
fi
392391

392+
if [ "$bridge_running" -ne 1 ]; then
393+
echo -e "${BOLD}broker connection:${RESET} disconnected (broker bridge process not running)"
394+
return 0
395+
fi
396+
393397
if [ ! -r "$health_file" ]; then
394398
echo -e "${BOLD}broker connection:${RESET} starting"
395399
echo -e "${BOLD}broker health:${RESET} unavailable (waiting for bridge health file)"

bin/doctor.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ fi
6767

6868
if command -v varlock &>/dev/null || [ -x "$BAUDBOT_HOME/.varlock/bin/varlock" ]; then
6969
pass "varlock is installed"
70+
if [ -f "$BAUDBOT_HOME/.varlock/config.json" ] && grep -q '"anonymousId"' "$BAUDBOT_HOME/.varlock/config.json"; then
71+
warn "$BAUDBOT_HOME/.varlock/config.json includes anonymousId (export VARLOCK_TELEMETRY_DISABLED=1 or remove this field)"
72+
fi
7073
else
7174
fail "varlock not found"
7275
fi

start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ cd ~
1616
# Set PATH
1717
export PATH="$HOME/.varlock/bin:$HOME/opt/node-v22.14.0-linux-x64/bin:$PATH"
1818

19+
# Work around varlock telemetry config crash by opting out at runtime.
20+
# This avoids loading anonymousId from user config and keeps startup deterministic.
21+
export VARLOCK_TELEMETRY_DISABLED=1
22+
1923
# Validate and load secrets via varlock
2024
varlock load --path ~/.config/ || {
2125
echo "❌ Environment validation failed — check ~/.config/.env against .env.schema"

0 commit comments

Comments
 (0)