askrobots / dbbasic-object-primitive
Public
Python functions as REST objects, with clustering, load balancing and state replication; no containers or orchestration.
restart_cluster.sh · 1.4 KB · 40 lines
| 1 | #!/bin/bash |
| 2 | # Restart heartbeat daemons on worker stations |
| 3 | # Run this from the master station after deploying new code |
| 4 | # Reads configuration from cluster.tsv |
| 5 | |
| 6 | # Load cluster configuration |
| 7 | eval "$(python cluster_shell_helper.py)" |
| 8 | |
| 9 | echo "=== Restarting Cluster Heartbeat Daemons ===" |
| 10 | echo |
| 11 | |
| 12 | # Restart worker 1 |
| 13 | if [ -n "$WORKER1_SSH" ]; then |
| 14 | echo "Restarting $WORKER1_ID ($WORKER1_HOST)..." |
| 15 | ssh "$WORKER1_SSH" "pkill -f cluster_heartbeat_daemon.py; sleep 1; cd ~/multiplexing && source .venv/bin/activate && nohup python cluster_heartbeat_daemon.py $MASTER_HOST --station-id $WORKER1_ID > heartbeat.log 2>&1 &" |
| 16 | echo "✓ $WORKER1_ID heartbeat restarted" |
| 17 | sleep 2 |
| 18 | echo |
| 19 | fi |
| 20 | |
| 21 | # Restart worker 2 |
| 22 | if [ -n "$WORKER2_SSH" ]; then |
| 23 | echo "Restarting $WORKER2_ID ($WORKER2_HOST)..." |
| 24 | ssh "$WORKER2_SSH" "pkill -f cluster_heartbeat_daemon.py; sleep 1; cd ~/multiplexing && source .venv/bin/activate && nohup python cluster_heartbeat_daemon.py $MASTER_HOST --station-id $WORKER2_ID > heartbeat.log 2>&1 &" |
| 25 | echo "✓ $WORKER2_ID heartbeat restarted" |
| 26 | sleep 2 |
| 27 | echo |
| 28 | fi |
| 29 | |
| 30 | echo "=== Heartbeat Daemons Restarted ===" |
| 31 | echo |
| 32 | |
| 33 | echo "Waiting 5 seconds for heartbeats to register..." |
| 34 | sleep 5 |
| 35 | echo |
| 36 | |
| 37 | echo "Cluster status:" |
| 38 | curl -s http://localhost:${MASTER_PORT}/cluster/stations | python3 -m json.tool | grep -E "station_id|version|is_active" | head -20 |
| 39 | echo |
| 40 | echo "✓ Check dashboard: http://localhost:${MASTER_PORT}/dashboard" |