Python functions as REST objects, with clustering, load balancing and state replication; no containers or orchestration.

0 downloads

dbbasic-object-primitive/start_cluster.sh
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-primitive.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-primitive.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-primitive.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Q Consolidate duplicate QUICKSTARTs on the top-level file 503f830 7 months ago History
start_cluster.sh · 1.9 KB · 51 lines
1#!/bin/bash
2# Start the entire cluster
3# Run this from the master station
4# Reads configuration from cluster.tsv
5
6# Load cluster configuration
7eval "$(python cluster_shell_helper.py)"
8
9echo "=== Starting ${WORKER_COUNT}-Station Cluster ==="
10echo
11
12echo "Starting master ($MASTER_ID - this machine)..."
13echo "Run manually in separate terminal:"
14echo " cd /Users/danq/multiplexing && source .venv/bin/activate && python run_server.py"
15echo
16
17echo "Starting workers..."
18echo
19
20# Start worker 1 (station2)
21if [ -n "$WORKER1_ID" ]; then
22 echo "Starting $WORKER1_ID ($WORKER1_HOST)..."
23 ssh "$WORKER1_SSH" "cd ~/multiplexing && source .venv/bin/activate && STATION_ID=$WORKER1_ID nohup .venv/bin/python run_server.py > server.log 2>&1 &"
24 sleep 2
25 ssh "$WORKER1_SSH" "cd ~/multiplexing && source .venv/bin/activate && nohup .venv/bin/python cluster_heartbeat_daemon.py $MASTER_HOST --station-id $WORKER1_ID > heartbeat.log 2>&1 &"
26 echo "✓ $WORKER1_ID started"
27 echo
28fi
29
30# Start worker 2 (station3)
31if [ -n "$WORKER2_ID" ]; then
32 echo "Starting $WORKER2_ID ($WORKER2_HOST)..."
33 ssh "$WORKER2_SSH" "cd ~/multiplexing && source .venv/bin/activate && STATION_ID=$WORKER2_ID nohup .venv/bin/python run_server.py > server.log 2>&1 &"
34 sleep 2
35 ssh "$WORKER2_SSH" "cd ~/multiplexing && source .venv/bin/activate && nohup .venv/bin/python cluster_heartbeat_daemon.py $MASTER_HOST --station-id $WORKER2_ID > heartbeat.log 2>&1 &"
36 echo "✓ $WORKER2_ID started"
37 echo
38fi
39
40echo "Waiting for stations to register..."
41sleep 3
42echo
43
44echo "=== Cluster Status ==="
45curl -s http://localhost:${MASTER_PORT}/cluster/stations | python3 -m json.tool
46
47echo
48echo "=== Cluster Ready ==="
49echo "Master: http://localhost:${MASTER_PORT}/dashboard"
50[ -n "$WORKER1_HOST" ] && echo "Worker 1: http://${WORKER1_HOST}:${WORKER1_PORT}/dashboard"
51[ -n "$WORKER2_HOST" ] && echo "Worker 2: http://${WORKER2_HOST}:${WORKER2_PORT}/dashboard"