set-active-slot.sh
bash
sha256:8e05daa29ba6702b4a2380a16d690ba31cc099d69c5c859bc6e6f16a0e945f99
Merge 'fix/deploy-memory-limits-and-log-group' into 'dev' —…
Human
5 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
3 commits
sha256:8e05daa29ba6702b4a2380a16d690ba31cc099d69c5c859bc6e6f16a0e945f99
Merge 'fix/deploy-memory-limits-and-log-group' into 'dev' —…
Human
5 days ago
sha256:3fadb0439bba9451b89229676971c0d4a40900dec7810e9d5f8791b8d950d505
fix: install.sh version from latest published tarball, not …
Sonnet 4.6
minor
⚠
96 days ago
sha256:763eb2cb8675073b84c19345b27586d2ed939a9aee97c5479b69f502f1a70eff
fix(tests): update test suite to match current implementation
Sonnet 4.6
patch
118 days ago