diff --git a/AGENTS.md b/AGENTS.md index 2d8b255..af6b97a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -586,11 +586,15 @@ unit tests (24) + box integration tests (2). - **Bot address / v7 relay gotcha.** The daemon must NOT run with `--headless` or `--relay`: in SimpleX Chat v7 `--headless` means "chat relay" (requires `--relay`) and yields a *relay* address, not a user contact address. Run bot - mode instead (`simplex-chat -p PORT --create-bot-display-name NAME`), which - needs no TTY and is restart-safe. `python scripts/simplex-address.py` then - shows (creating on first run, via `/_address` / `/_show_address `) - the bot's user contact link, which a human adds in their SimpleX app to start - a DM. `bootstrap.sh` prints it at the end of provisioning. + mode instead (`simplex-chat -p PORT --create-bot-display-name NAME`). **The + CLI only pumps WebSocket events while it has a controlling terminal**, so the + unit wraps it in `script -q -e -c '…' /dev/null` to allocate a PTY: a TTY-less + process (plain `ExecStart=` under systemd) accepts the socket but never emits + `receivedContactRequest`/`newChatItems`, so contact requests hang forever. + `python scripts/simplex-address.py` then shows (creating on first run, via + `/_address` / `/_show_address `) the bot's user contact link, which a + human adds in their SimpleX app to start a DM. `bootstrap.sh` prints it at the + end of provisioning. - **Transport contract** (`gateway/base.py`): `GatewayAdapter.run(on_inbound, outbound_queue)` blocks, delivering `InboundMessage`s and draining a stdlib `queue.Queue[OutboundMessage | None]`. Scheduler work is synchronous and can diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index f35b928..b195742 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -136,7 +136,7 @@ echo "== runtime tree: $RUNTIME" mkdir -p "$RUNTIME" "$MODELS" "$HF_CACHE" "$TOOLDIR" "$SIMPLEX_DB" "$UNITS" "$USER_UNITS" # --- stage 0: system prereqs + linger ---------------------------------------- -PKGS=(ca-certificates curl git rsync build-essential python3-dev python3-venv pkg-config cmake) +PKGS=(ca-certificates curl git rsync build-essential python3-dev python3-venv pkg-config cmake util-linux) missing=() for p in "${PKGS[@]}"; do dpkg -s "$p" >/dev/null 2>&1 || missing+=("$p") diff --git a/scripts/systemd/semif-simplex.service.in b/scripts/systemd/semif-simplex.service.in index f889f69..0ad5f29 100644 --- a/scripts/systemd/semif-simplex.service.in +++ b/scripts/systemd/semif-simplex.service.in @@ -8,7 +8,10 @@ Type=simple # Bot mode: a local WebSocket chat server with a bot user. Do NOT add # --headless here — in SimpleX Chat v7 --headless means "chat relay" and # requires --relay, which yields a relay address, not a user contact address. -ExecStart=@REPO@/.runtime/bin/simplex-chat -p @PORT@ -d @REPO@/.runtime/simplex/simplex_v1 -k "" --create-bot-display-name "@DISPLAY_NAME@" +# The CLI only pumps WebSocket events (receivedContactRequest, newChatItems) +# when it has a controlling terminal, so `script` allocates a PTY; without it +# systemd's TTY-less process receives no events and contact requests hang. +ExecStart=/usr/bin/script -q -e -c "@REPO@/.runtime/bin/simplex-chat -p @PORT@ -d @REPO@/.runtime/simplex/simplex_v1 -k '' --create-bot-display-name '@DISPLAY_NAME@'" /dev/null Restart=always RestartSec=10 StandardOutput=journal