Skip to content

Commit 8f5441e

Browse files
a692570claude
andcommitted
fix: restore auto-restart supervisor loop in start-bolo.command and restart.sh
Uses a lock dir at /tmp/bolo-supervisor.lock to prevent duplicate supervisors. Supervisor runs in background so Terminal can close after launch. restart.sh kills existing supervisor+bolo, removes stale lock, starts fresh loop. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 2200d3e commit 8f5441e

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

restart.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
#!/bin/bash
2-
# Restart Bolo — must be run from a Terminal session (for Accessibility inheritance).
3-
set -e
2+
# Restart Bolo -- must be run from a Terminal session (for Accessibility inheritance).
43

54
DIR="$(cd "$(dirname "$0")" && pwd)"
5+
LOCK_DIR=/tmp/bolo-supervisor.lock
66

7+
# Kill existing supervisor and bolo processes
78
pkill -f "bolo.py" 2>/dev/null || true
89
pkill -f "overlay.py" 2>/dev/null || true
10+
11+
# Remove stale supervisor lock so start-bolo.command can acquire it
12+
rmdir "$LOCK_DIR" 2>/dev/null || true
13+
914
sleep 1
1015

11-
nohup python3 "$DIR/bolo.py" > /tmp/bolo.log 2>&1 &
12-
echo "Bolo restarted (PID $!)"
16+
# Start a fresh supervisor loop in background
17+
(
18+
mkdir "$LOCK_DIR" 2>/dev/null || true
19+
while true; do
20+
python3 "$DIR/bolo.py" >> /tmp/bolo.log 2>&1
21+
echo "[bolo] crashed -- restarting in 3s" >> /tmp/bolo.log
22+
sleep 3
23+
done
24+
) &
25+
26+
echo "[bolo] restarted (supervisor PID $!)"

start-bolo.command

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
#!/bin/bash
2-
# Bolo launcher designed to run as a Login Item (opens in Terminal).
2+
# Bolo launcher -- designed to run as a Login Item (opens in Terminal).
33
# Terminal.app must have Accessibility + Microphone permissions in System Settings.
44
# Running python3 from Terminal inherits those permissions.
55

66
BOLO_DIR=/Users/abhisheksharma/bolo
7+
LOCK_DIR=/tmp/bolo-supervisor.lock
8+
9+
# Prevent duplicate supervisors
10+
if mkdir "$LOCK_DIR" 2>/dev/null; then
11+
trap "rmdir '$LOCK_DIR' 2>/dev/null; exit" EXIT INT TERM
12+
else
13+
echo "[bolo] supervisor already running (lock exists). Exiting."
14+
exit 0
15+
fi
716

817
pkill -f "bolo.py" 2>/dev/null || true
918
pkill -f "overlay.py" 2>/dev/null || true
1019
sleep 1
1120

12-
nohup python3 "$BOLO_DIR/bolo.py" > /tmp/bolo.log 2>&1 &
13-
sleep 2
21+
# Run supervisor loop in background so Terminal can close
22+
(
23+
while true; do
24+
python3 "$BOLO_DIR/bolo.py" >> /tmp/bolo.log 2>&1
25+
echo "[bolo] crashed -- restarting in 3s" >> /tmp/bolo.log
26+
sleep 3
27+
done
28+
) &
29+
30+
echo "[bolo] supervisor started (PID $!)"
31+
sleep 1
1432
exit 0

0 commit comments

Comments
 (0)