Claude/explain codebase mlo58wlz5o1uwxwa wiq er#586
Open
yinghuizhou wants to merge 6 commits intoWei-Shaw:mainfrom
Open
Claude/explain codebase mlo58wlz5o1uwxwa wiq er#586yinghuizhou wants to merge 6 commits intoWei-Shaw:mainfrom
yinghuizhou wants to merge 6 commits intoWei-Shaw:mainfrom
Conversation
Automatically checks Wei-Shaw/sub2api daily and creates PR when updates are found. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ection The OpenAI gateway's handleStreamingAwareError used fmt.Sprintf with %s to embed errType and message directly into a JSON string. When upstream error messages contain characters like `"` or `\` (e.g. 'model "gpt-xxx" not found'), this produces malformed JSON that clients cannot parse. Fix by using json.Marshal, consistent with the Claude gateway's handleStreamingAwareError which already does this correctly. https://claude.ai/code/session_01GzEbgf1NvhMq4mA4M6vQFg
Author
|
merged |
Triggers on push to main or manual dispatch. SSHes into the server, pulls latest code, builds Docker image locally, and restarts the sub2api service via docker compose. Requires GitHub Secrets: SERVER_HOST, SERVER_USER, SERVER_SSH_KEY, PROJECT_DIR. https://claude.ai/code/session_01GzEbgf1NvhMq4mA4M6vQFg
… and auto-rollback - 4-stage health verification: container status, HTTP health, DB/Redis, API smoke tests - Automatic rollback on verification failure - Auto-update mode via cron (--cron flag) for hands-off deployments - Only deploys when new image is detected (--auto mode) - Full deployment logging with timestamps - Manual rollback support (--rollback) - Status inspection (--status) https://claude.ai/code/session_01GzEbgf1NvhMq4mA4M6vQFg
Architecture: - Nginx reverse proxy as user entry point (zero-disconnect reload) - Blue/Green dual instances behind Nginx - Traffic only switches AFTER new instance passes all health checks Deploy flow (users notice nothing): 1. Pull new image 2. Start standby instance (blue→green or green→blue) 3. 4-stage verification on standby (HTTP health, DB/Redis, API smoke, panic check) 4. Pass → Nginx reload to new instance → graceful shutdown old instance 5. Fail → Remove standby, production untouched Files: - safe-deploy.sh: Full blue-green orchestration with --init, --auto, --cron, --rollback - docker-compose.bluegreen.yml: Dual sub2api instances + Nginx + PostgreSQL + Redis - nginx/nginx.conf: Reverse proxy with SSE/streaming/WebSocket support - nginx/upstream.conf: Dynamic upstream managed by safe-deploy.sh https://claude.ai/code/session_01GzEbgf1NvhMq4mA4M6vQFg
Bugs found and fixed during thorough code audit: 1. [CRITICAL] upstream.conf: had "127.0.0.1:8081" instead of Docker hostname "sub2api-blue:8080" - Nginx would fail to resolve upstream on Docker network 2. [CRITICAL] do_init(): conditional write `if [ ! -f ]` meant the wrong upstream.conf from git would never be overwritten - now forces correct value 3. [HIGH] Nginx depends_on sub2api-blue: hard dependency caused failure when green was active and someone ran `docker compose up` - removed dependency, upstream.conf alone controls routing 4. [HIGH] nginx.conf Connection header: hardcoded "upgrade" on every request broke SSE streaming - now uses `map $http_upgrade` for conditional WebSocket upgrade only when client requests it 5. [MEDIUM] switch_nginx(): `docker exec ...; if [ $? -eq 0 ]` unreachable under `set -e` - changed to `if docker exec ...; then` 6. [MEDIUM] do_deploy() standby startup: complex `||` fallback chain had unpredictable behavior under `set -e` - simplified to explicit if/else with profile handling and post-startup running check Also added: docker exec fallback for health checks when container IP is unreachable (rootless Docker, non-standard network configs). https://claude.ai/code/session_01GzEbgf1NvhMq4mA4M6vQFg
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.