Files
waste-go/launch-web.sh.example
Fredrik Johansson d07342e97e docs: fix placeholder URLs in QUICKSTART; add committed example scripts
QUICKSTART.md had the author's personal domain as the example anchor URL
(wss://waste.dev.xplwd.com/ws) which would confuse anyone reading it.
Replaced with wss://YOUR_ANCHOR_DOMAIN/ws and added a new Option 3
section explaining the example scripts.

Added committed *.example versions of the four local-workflow scripts
(launch-tui, launch-web, deploy-web, serve-web). The real filenames are
gitignored so local edits (HOST, ANCHOR, etc.) are never accidentally
committed; the .example files serve as templates users copy once.
Each script fails fast if the placeholder URL/host is still set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 11:51:02 +02:00

75 lines
2.0 KiB
Bash

#!/usr/bin/env bash
# launch-web.sh — start the daemon and open the web UI Vite dev server.
# For local development / daemon-mode browsing.
#
# SETUP: copy this file to launch-web.sh (gitignored) and set ANCHOR below.
#
# Usage:
# ./launch-web.sh
# ALIAS=alice NETWORK=friends ./launch-web.sh
set -euo pipefail
ANCHOR="${ANCHOR:-wss://YOUR_ANCHOR_DOMAIN/ws}" # ← edit this
NETWORK="${NETWORK:-friends}"
ALIAS="${ALIAS:-${USER:-anon}}"
DATA_DIR="${DATA_DIR:-${HOME}/.waste-${ALIAS}}"
IPC_PORT="${IPC_PORT:-17337}"
WS_PORT=$(( IPC_PORT + 1 ))
if [[ "$ANCHOR" == *YOUR_ANCHOR_DOMAIN* ]]; then
echo "error: edit ANCHOR in this script (or export ANCHOR=wss://... before running)" >&2
exit 1
fi
PIDS=()
cleanup() {
for pid in "${PIDS[@]:-}"; do kill "$pid" 2>/dev/null || true; done
wait 2>/dev/null || true
}
trap cleanup EXIT INT TERM
for port in "$IPC_PORT" "$WS_PORT"; do
existing=$(lsof -ti tcp:"$port" 2>/dev/null || true)
[ -n "$existing" ] && kill "$existing" 2>/dev/null || true
done
for port in "$IPC_PORT" "$WS_PORT"; do
n=0
while lsof -ti tcp:"$port" >/dev/null 2>&1; do
sleep 0.1; n=$(( n + 1 )); [ "$n" -gt 30 ] && break
done
done
mkdir -p "$DATA_DIR"
echo "alias : $ALIAS"
echo "network : $NETWORK"
echo "anchor : $ANCHOR"
echo "ws-port : $WS_PORT"
echo ""
echo "building daemon…"
go build -o /tmp/waste-daemon-web ./cmd/daemon
/tmp/waste-daemon-web \
-alias "$ALIAS" -data-dir "$DATA_DIR" \
-ipc-port "$IPC_PORT" -ws-port "$WS_PORT" \
-anchor "$ANCHOR" \
2>/tmp/waste-daemon-web.log &
PIDS+=($!)
n=0
while ! nc -z 127.0.0.1 "$IPC_PORT" 2>/dev/null; do
sleep 0.1; n=$(( n + 1 ))
[ "$n" -gt 80 ] && echo "daemon failed to start — check /tmp/waste-daemon-web.log" >&2 && exit 1
done
sleep 0.2
jq -cn --arg net "$NETWORK" '{"type":"join_network","network_name":$net}' \
| nc -q0 127.0.0.1 "$IPC_PORT" >/dev/null 2>&1 || true
echo "daemon ready — joined $NETWORK"
echo ""
npm run dev --prefix "$(dirname "$0")/web"