feat(doorbell-touch): add lockfile to prevent concurrent monitor sessions
This commit is contained in:
12
mise.toml
12
mise.toml
@@ -49,6 +49,18 @@ arduino-cli upload --fqbn "$FQBN" --port "$PORT" ./boards/$BOARD
|
|||||||
description = "Monitor (uses BOARD env var)"
|
description = "Monitor (uses BOARD env var)"
|
||||||
run = """
|
run = """
|
||||||
source ./boards/$BOARD/board-config.sh
|
source ./boards/$BOARD/board-config.sh
|
||||||
|
|
||||||
|
LOCKFILE="/tmp/doorbell-$BOARD.lock"
|
||||||
|
if [ -f "$LOCKFILE" ]; then
|
||||||
|
echo "Error: Another instance is running (lockfile exists: $LOCKFILE)"
|
||||||
|
echo "Remove with: rm $LOCKFILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
trap 'rm -f "$LOCKFILE"' EXIT
|
||||||
|
touch "$LOCKFILE"
|
||||||
|
|
||||||
|
echo "Acquired lock: $LOCKFILE (Ctrl+C to release)"
|
||||||
|
|
||||||
PORT="${PORT:-$PORT}"
|
PORT="${PORT:-$PORT}"
|
||||||
TARGET="$(readlink -f "$PORT" 2>/dev/null || echo "$PORT")"
|
TARGET="$(readlink -f "$PORT" 2>/dev/null || echo "$PORT")"
|
||||||
arduino-cli monitor -p "$TARGET" --config baudrate=115200
|
arduino-cli monitor -p "$TARGET" --config baudrate=115200
|
||||||
|
|||||||
Reference in New Issue
Block a user