Add eagle-exec helper for blue-green deployments (#5567)

Adds a helper script that automatically runs docker exec against the
active Eagle instance (blue or green), determined by checking nginx
config.

Usage:
  eagle-exec printenv GEMINI_API_KEY
  eagle-exec jcmd 1 VM.flags
  eagle-exec sh

The script is deployed to /opt/eagle0/scripts/ and symlinked to
/usr/local/bin/eagle-exec for easy access.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-23 10:31:53 -08:00
committed by GitHub
co-authored by Claude Opus 4.5
parent 21dfa12197
commit 84c1bf61b0
2 changed files with 57 additions and 1 deletions
+54
View File
@@ -0,0 +1,54 @@
#!/bin/bash
#
# Helper to run docker exec against the active Eagle instance.
# Automatically determines whether blue or green is active based on nginx config.
#
# Usage:
# ./scripts/eagle-exec.sh printenv GEMINI_API_KEY
# ./scripts/eagle-exec.sh jcmd 1 VM.flags
# ./scripts/eagle-exec.sh sh # Get a shell
#
# Or create an alias:
# alias eagle-exec='/opt/eagle0/scripts/eagle-exec.sh'
#
set -euo pipefail
APP_DIR="${APP_DIR:-/opt/eagle0}"
# Determine active instance from nginx config
get_active_instance() {
local backend
backend=$(docker exec nginx grep -o 'eagle-[a-z]*:40032' /etc/nginx/nginx.conf 2>/dev/null | head -1 || echo "")
if [ "$backend" = "eagle-blue:40032" ]; then
echo "eagle-blue"
elif [ "$backend" = "eagle-green:40032" ]; then
echo "eagle-green"
else
# Fallback: check which container is actually running
if docker inspect --format='{{.State.Running}}' eagle-blue 2>/dev/null | grep -q true; then
echo "eagle-blue"
elif docker inspect --format='{{.State.Running}}' eagle-green 2>/dev/null | grep -q true; then
echo "eagle-green"
else
echo ""
fi
fi
}
ACTIVE=$(get_active_instance)
if [ -z "$ACTIVE" ]; then
echo "Error: No active Eagle instance found" >&2
exit 1
fi
if [ $# -eq 0 ]; then
echo "Active instance: $ACTIVE"
echo "Usage: $0 <command> [args...]"
echo "Example: $0 printenv GEMINI_API_KEY"
exit 0
fi
exec docker exec "$ACTIVE" "$@"