swactor/examples/ping-pong/serve.sh
Zachery Aaron Shores-Chmielewski 966497ec07 feat: proper README, LICENSE, and our first quick example
Add project licensing and a full README, plus a minimal WebAssembly ping-pong example that exercises the actor runtime.

- `LICENSE`: add the full GNU AGPL-3.0 text and set `license = "AGPL-3.0-only"` on every package (`swactor`, each crate, `apps/myelin`, `tools/vastai`, `xtask`)
- `README.md`: rewrite from a stub into a full project overview, covering features (actor_id routing, WASM, iroh QUIC/SWIM, OTP-style std, process manager, zero-copy objects, datastream metrics, dashboard), architecture, examples, developing, status, and license
- `examples/ping-pong`: new standalone workspace (`pingpong` cdylib) where two actors volley on a single-threaded `wasm` runtime driven by a Node host via `tick()`, demonstrating spawning, message passing, and death monitoring (`watching`)
- `examples/ping-pong`: add a host/run harness -- `run.sh` (wasm-pack build + `run.mjs`), `serve.sh` (dashboard + static demo), `index.html`, and a pinned `Cargo.lock`
- `.gitignore`: stop ignoring `.loop/`, `.deployment-notes/`, and `.omp/`

Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-08-06 00:53:16 +04:00

40 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# swactor live demo -- serve the ping-pong wasm page AND the swactor dashboard.
#
# One-liner from this directory: ./serve.sh [port]
#
# Brings up two local servers:
# - swactor dashboard (native Rust; a dummy node feeds it live actor stats)
# at http://localhost:9090/
# - ping-pong wasm demo (static files)
# at http://localhost:<port>/ (default 8000)
#
# Ctrl+C stops both.
set -euo pipefail
cd "$(dirname "$0")"
ROOT="$(cd ../.. && pwd)"
port="${1:-8000}"
dash_port=9090
# --- swactor dashboard -------------------------------------------------------
# The dashboard is a workspace member; build it from the root manifest, then run
# the dummy-node binary, which starts the Axum server and publishes live stats.
echo ">> building swactor dashboard..."
cargo build --manifest-path "$ROOT/Cargo.toml" -p dashboard --bin swactor_dummy_node
echo ">> launching dashboard on :${dash_port}"
"$ROOT/target/debug/swactor_dummy_node" &
dash_pid=$!
cleanup() { kill "$dash_pid" 2>/dev/null || true; wait "$dash_pid" 2>/dev/null || true; }
trap cleanup EXIT INT TERM
# --- ping-pong wasm page -----------------------------------------------------
wasm-pack build --target web --out-name pingpong --out-dir pkg-web
echo
echo ">> ping-pong : http://localhost:${port}/"
echo ">> dashboard : http://localhost:${dash_port}/ (live swactor stats)"
echo ">> (Ctrl+C to stop)"
echo
python3 -m http.server "$port"