set-active-slot.sh
bash
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7
test(mwp3): Phase 4 — fix adjacent suite regressions, lock …
Sonnet 4.6
22 days ago
| 1 | #!/usr/bin/env bash |
| 2 | # /usr/local/bin/musehub-set-slot |
| 3 | # |
| 4 | # The only sanctioned way to switch MuseHub's nginx upstream between blue and green. |
| 5 | # Accepts a slot name, constructs the correct nginx directive, validates, and reloads. |
| 6 | # |
| 7 | # Usage: |
| 8 | # sudo musehub-set-slot blue |
| 9 | # sudo musehub-set-slot green |
| 10 | # |
| 11 | # Called by deploy.sh automatically. For manual recovery: |
| 12 | # sudo musehub-set-slot blue ← blue is port 1337 |
| 13 | # sudo musehub-set-slot green ← green is port 1338 |
| 14 | |
| 15 | set -euo pipefail |
| 16 | |
| 17 | NGINX_PORT_FILE="/etc/nginx/musehub-active-port" |
| 18 | SLOT_FILE="/opt/musehub/.active-slot" |
| 19 | |
| 20 | slot="${1:-}" |
| 21 | |
| 22 | case "$slot" in |
| 23 | blue) port=1337 ;; |
| 24 | green) port=1338 ;; |
| 25 | *) |
| 26 | echo "ERROR: slot must be 'blue' or 'green', got: '$slot'" >&2 |
| 27 | echo "Usage: sudo musehub-set-slot blue|green" >&2 |
| 28 | exit 1 |
| 29 | ;; |
| 30 | esac |
| 31 | |
| 32 | echo "server 127.0.0.1:${port};" > "$NGINX_PORT_FILE" |
| 33 | echo "$slot" > "$SLOT_FILE" |
| 34 | |
| 35 | nginx -t 2>&1 || { echo "ERROR: nginx config test failed — aborting" >&2; exit 1; } |
| 36 | nginx -s reload |
| 37 | echo "nginx → $slot (127.0.0.1:${port})" |
File History
2 commits
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7
test(mwp3): Phase 4 — fix adjacent suite regressions, lock …
Sonnet 4.6
22 days ago
sha256:1749b9cc5cd2583c56d3261c4c00a342c27435f3946d4bc3e70f76aa2795458a
docs(mwp-3): TDD implementation plan for job-enqueue idempo…
Opus 4.8
22 days ago