#!/usr/bin/env bash # Launch one more Electron window against an already-running dev stack. # # Electron's single-instance lock is scoped to the userData directory, so a peer # window only gets its own lock — and its own identity — when it gets its own # --user-data-dir. Without that, tools/launch-electron.js hands its argv to the # running instance and the dev-reload path just reloads window A instead. set -e DIR="$(cd "$(dirname "$0")" && pwd)" PEER_NAME="${1:-peer}" PEER_DATA_DIR="$DIR/.dev-userdata/$PEER_NAME" if [ -f "$DIR/.env" ]; then set -a source "$DIR/.env" set +a fi SSL="${SSL:-false}" if [ "$SSL" = "true" ]; then CLIENT_URL="https://127.0.0.1:4200" export NODE_TLS_REJECT_UNAUTHORIZED=0 else CLIENT_URL="http://127.0.0.1:4200" fi if ! npx wait-on --timeout 5000 "$CLIENT_URL" >/dev/null 2>&1; then echo "No dev client at $CLIENT_URL — start the stack with 'npm run dev' first." >&2 exit 1 fi mkdir -p "$PEER_DATA_DIR" echo "Launching peer window '$PEER_NAME' (data dir: $PEER_DATA_DIR)" echo "Reminder: a fresh peer needs https://localhost:3001 added under Settings -> signal servers." exec npx cross-env NODE_ENV=development SSL="$SSL" node tools/launch-electron.js . \ --no-sandbox \ --disable-dev-shm-usage \ --user-data-dir="$PEER_DATA_DIR"