From 95129e623a4e5a0ae194ba4824c6b89f83902326 Mon Sep 17 00:00:00 2001 From: Chenyme <118253778+chenyme@users.noreply.github.com> Date: Fri, 10 Apr 2026 18:15:27 +0800 Subject: [PATCH] chore: update Dockerfile healthcheck command and bump version to 2.0.4.rc0 in pyproject.toml and uv.lock; improve error handling in xai_usage.py --- Dockerfile | 2 +- app/control/model/registry.py | 2 +- app/dataplane/account/sync.py | 1 - app/dataplane/reverse/protocol/xai_usage.py | 7 ++++++- pyproject.toml | 2 +- uv.lock | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f983808..a48752ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,7 +71,7 @@ RUN mkdir -p /app/data /app/logs \ EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ - CMD wget -qO /dev/null http://localhost:${SERVER_PORT}/health || exit 1 + CMD ["sh", "-c", "wget -qO /dev/null http://127.0.0.1:${SERVER_PORT}/health || exit 1"] ENTRYPOINT ["/app/scripts/entrypoint.sh"] CMD ["sh", "-c", "exec granian --interface asgi --host ${SERVER_HOST} --port ${SERVER_PORT} --workers ${SERVER_WORKERS} app.main:app"] diff --git a/app/control/model/registry.py b/app/control/model/registry.py index 851252ae..573aa7f5 100644 --- a/app/control/model/registry.py +++ b/app/control/model/registry.py @@ -13,7 +13,7 @@ MODELS: tuple[ModelSpec, ...] = ( # Basic+ ModelSpec("grok-4.20-0309-non-reasoning", ModeId.FAST, Tier.BASIC, Capability.CHAT, True, "Grok 4.20 0309 Non-Reasoning"), - ModelSpec("grok-4.20-0309", ModeId.AUTO, Tier.BASIC, Capability.CHAT, True, "Grok 4.20-0309"), + ModelSpec("grok-4.20-0309", ModeId.AUTO, Tier.BASIC, Capability.CHAT, True, "Grok 4.20 0309"), ModelSpec("grok-4.20-0309-reasoning", ModeId.EXPERT, Tier.BASIC, Capability.CHAT, True, "Grok 4.20 0309 Reasoning"), # Super+ ModelSpec("grok-4.20-0309-non-reasoning-super", ModeId.FAST, Tier.SUPER, Capability.CHAT, True, "Grok 4.20 0309 Non-Reasoning Super"), diff --git a/app/dataplane/account/sync.py b/app/dataplane/account/sync.py index 40e84e73..c0231bf2 100644 --- a/app/dataplane/account/sync.py +++ b/app/dataplane/account/sync.py @@ -120,7 +120,6 @@ async def apply_changes( table._update_slot(existing, **args, old_tags=old_tags, new_tags=tags) else: table._append_slot(record.token, **args, tags=tags) - table.size += 1 changed = True diff --git a/app/dataplane/reverse/protocol/xai_usage.py b/app/dataplane/reverse/protocol/xai_usage.py index 00e0310d..5ec68f82 100644 --- a/app/dataplane/reverse/protocol/xai_usage.py +++ b/app/dataplane/reverse/protocol/xai_usage.py @@ -1,5 +1,7 @@ """XAI rate-limits API protocol — fetch live quota data per mode.""" +import asyncio + import orjson from app.platform.errors import UpstreamError @@ -124,7 +126,10 @@ async def _fetch_one(token: str, mode_id: int) -> object | None: """Fetch quota window for a single mode. Returns QuotaWindow or None.""" mode_name = _MODE_NAMES.get(mode_id, "auto") try: - body = await _do_fetch(token, mode_name) + body = await asyncio.wait_for(_do_fetch(token, mode_name), timeout=25.0) + except asyncio.TimeoutError: + logger.debug("rate-limits fetch timed out: token={}... mode={}", token[:10], mode_name) + return None except Exception as exc: if is_invalid_credentials_error(exc): raise diff --git a/pyproject.toml b/pyproject.toml index 91addebb..5ada84d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "grok2api" -version = "2.0.2" +version = "2.0.4.rc0" description = "Grok2API rebuilt with FastAPI, fully aligned with the latest web call format. Supports streaming and non-streaming chat, image generation/editing, deep thinking, token pool concurrency, and automatic load balancing." readme = "README.md" requires-python = ">=3.13" diff --git a/uv.lock b/uv.lock index 952ca145..a6bfbd41 100644 --- a/uv.lock +++ b/uv.lock @@ -580,7 +580,7 @@ wheels = [ [[package]] name = "grok2api" -version = "2.0.2" +version = "2.0.4rc0" source = { virtual = "." } dependencies = [ { name = "aiohttp" },