gabriel / musehub public
set-active-slot.sh bash
37 lines 1.0 KB
Raw
sha256:3ff9c9863a9891bdcde71b4a43228f66d0493e38b7cc1d09fe9eb7de774046b2 feat: add repair-commit wire endpoint (API parity with repa… Opus 4.8 minor ⚠ breaking 1 day 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 1 commit
sha256:3ff9c9863a9891bdcde71b4a43228f66d0493e38b7cc1d09fe9eb7de774046b2 feat: add repair-commit wire endpoint (API parity with repa… Opus 4.8 minor 1 day ago