Last active
March 18, 2026 02:25
-
-
Save jonschull/b72db8ca1651e9ab6e957e8fb9d352fa to your computer and use it in GitHub Desktop.
ERA pipeline Render spike startup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "=== ERA Pipeline Spike v4 ===" | |
| echo "Date: $(date -u)" | |
| echo "Memory: $(free -m 2>/dev/null || echo 'free not available')" | |
| # Phase 1: Install Node.js and Claude Code | |
| echo "=== PHASE 1: Installing Node.js ===" | |
| if ! command -v node &> /dev/null; then | |
| curl -fsSL https://deb.nodesource.com/setup_20.x | bash - 2>&1 | |
| apt-get install -y nodejs 2>&1 | |
| fi | |
| echo "Node: $(node --version), npm: $(npm --version)" | |
| echo "=== PHASE 1b: Installing Claude Code ===" | |
| npm install -g @anthropic-ai/claude-code 2>&1 | |
| echo "Claude: $(claude --version 2>&1)" | |
| # Phase 2: Test Anthropic API directly with curl (no Node overhead) | |
| echo "=== PHASE 2: Testing Anthropic API via curl ===" | |
| echo "ANTHROPIC_API_KEY set: $([ -n "$ANTHROPIC_API_KEY" ] && echo yes || echo no)" | |
| API_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" \ | |
| https://api.anthropic.com/v1/messages \ | |
| -H "content-type: application/json" \ | |
| -H "x-api-key: $ANTHROPIC_API_KEY" \ | |
| -H "anthropic-version: 2023-06-01" \ | |
| -d '{"model":"claude-sonnet-4-20250514","max_tokens":50,"messages":[{"role":"user","content":"What is 2+2? Reply with just the number."}]}') | |
| echo "API Response: $API_RESPONSE" | |
| echo "=== PHASE 2 DONE ===" | |
| # Phase 2b: Test claude --print with memory monitoring | |
| echo "=== PHASE 2b: Testing claude --print ===" | |
| echo "Memory before claude --print: $(free -m 2>/dev/null | grep Mem || echo 'N/A')" | |
| timeout 120 claude --print "Reply with just: OK" > /tmp/claude_out.txt 2>&1 & | |
| CLAUDE_PID=$! | |
| echo "Claude PID: $CLAUDE_PID" | |
| # Monitor memory while claude runs | |
| for i in 1 2 3 4 5 10 15 20 30 45 60; do | |
| sleep $((i > 5 ? 5 : i)) | |
| if kill -0 $CLAUDE_PID 2>/dev/null; then | |
| echo "t=${i}s: PID $CLAUDE_PID alive, RSS=$(ps -o rss= -p $CLAUDE_PID 2>/dev/null || echo '?')KB" | |
| else | |
| wait $CLAUDE_PID 2>/dev/null | |
| echo "t=${i}s: PID $CLAUDE_PID exited with $?" | |
| break | |
| fi | |
| done | |
| wait $CLAUDE_PID 2>/dev/null | |
| CLAUDE_EXIT=$? | |
| echo "Claude --print exit code: $CLAUDE_EXIT" | |
| echo "Claude --print output:" | |
| cat /tmp/claude_out.txt 2>/dev/null | |
| echo "---end---" | |
| # Phase 3: Install and test gh CLI | |
| echo "=== PHASE 3: Installing gh CLI ===" | |
| if ! command -v gh &> /dev/null; then | |
| apt-get install -y gpg 2>&1 | tail -3 | |
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg 2>&1 | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list | |
| apt-get update 2>&1 | tail -3 | |
| apt-get install -y gh 2>&1 | tail -3 | |
| fi | |
| echo "gh: $(gh --version 2>&1 | head -1)" | |
| echo "$GH_TOKEN" | gh auth login --with-token 2>&1 | |
| gh issue list --repo jonschull/ERA_Admin --limit 3 2>&1 | |
| echo "=== PHASE 3 DONE ===" | |
| # Phase 4: Clone repo and test listener dry-run | |
| echo "=== PHASE 4: Testing listener ===" | |
| if [ ! -d /tmp/era2c ]; then | |
| git clone --depth 1 https://x-access-token:${GH_TOKEN}@github.com/jonschull/ERA_Admin.git /tmp/era2c 2>&1 | tail -3 | |
| fi | |
| cd /tmp/era2c | |
| pip install -r requirements.txt 2>&1 | tail -5 | |
| pip install PyGithub 2>&1 | tail -3 | |
| python3 scripts/gh_listener.py --dry-run 2>&1 | head -50 | |
| echo "=== PHASE 4 DONE ===" | |
| echo "=== ALL PHASES COMPLETE at $(date -u) ===" | |
| sleep infinity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment