feat(cluster): deploy browser WebSocket + CORS to the 3-node cluster
Roll the --ws-port + --cors-origins flags (issue uniweb/0001) out to the unibus cluster so the browser-native uniweb client can reach the data plane (nats.ws) and the control plane (CORS) on every node. The WS reuses the data-plane TLS (wss://) and the same origin allowlist. Per-node WS port override (WS_PORT_<NAME>): magnus runs unibus_admin on 127.0.0.1:8480, so the bus WS binds 8485 there to avoid a crash-loop; homer and datardos keep 8480. deploy-cluster.sh also gains DEPLOY_ONLY=<name> for rolling one node at a time. Rolled out and verified 2026-06-13: all three nodes healthy, WS reachable, CORS 204, cluster quorum (R3) intact throughout.
This commit is contained in:
@@ -69,6 +69,12 @@ routes_for() {
|
||||
echo "==> [2/3] stage each node (REMOTE_DIR=$REMOTE_DIR)"
|
||||
for row in "${CLUSTER_NODES[@]}"; do
|
||||
read -r name ssh _pub _wg <<<"$row"
|
||||
# Rolling deploy: DEPLOY_ONLY=<name> stages just that node, so a new binary can be
|
||||
# rolled out one node at a time (the other nodes keep the cluster quorum). Empty =
|
||||
# stage every node (the original behavior).
|
||||
if [[ -n "${DEPLOY_ONLY:-}" && "$name" != "$DEPLOY_ONLY" ]]; then
|
||||
continue
|
||||
fi
|
||||
target="${SSH_USER}@${ssh}"
|
||||
nodedir="out/${name}"
|
||||
if [[ ! -d "$nodedir" ]]; then
|
||||
@@ -79,6 +85,13 @@ for row in "${CLUSTER_NODES[@]}"; do
|
||||
|
||||
echo "-- node ${name} (ssh ${ssh}) routes=${routes}"
|
||||
|
||||
# Resolve this node's WebSocket port. magnus runs unibus_admin on 127.0.0.1:8480,
|
||||
# so the bus WS cannot bind 0.0.0.0:8480 there (it crash-loops). A per-node
|
||||
# override (WS_PORT_<NAME> in nodes.env) lets magnus use a free port while the
|
||||
# rest share the default — keeping the deploy reproducible (issue uniweb/0001).
|
||||
node_ws_var="WS_PORT_${name^^}"
|
||||
node_ws="${!node_ws_var:-$WS_PORT}"
|
||||
|
||||
# Generate this node's cluster.env locally, then ship it.
|
||||
envfile="build/cluster-${name}.env"
|
||||
mkdir -p build
|
||||
@@ -90,6 +103,8 @@ KV_REPLICAS=${KV_REPLICAS}
|
||||
HTTP_PORT=${HTTP_PORT}
|
||||
NATS_CLIENT_PORT=${NATS_CLIENT_PORT}
|
||||
NATS_ROUTE_PORT=${NATS_ROUTE_PORT}
|
||||
WS_PORT=${node_ws}
|
||||
CORS_ORIGINS=${CORS_ORIGINS}
|
||||
ROUTES=${routes}
|
||||
CLUSTER_PASS_FILE=${REMOTE_DIR}/secrets/cluster.pass
|
||||
TLS_CERT=${REMOTE_DIR}/tls/server-${name}.crt
|
||||
|
||||
Reference in New Issue
Block a user