From 046c846c4ceb85396333b1d917979ae7fca2fc74 Mon Sep 17 00:00:00 2001 From: RyanVan <150385913+Ryson-32@users.noreply.github.com> Date: Wed, 24 Jun 2026 14:35:13 +0800 Subject: [PATCH] fix: align v2.5.0 selfhost doctor --- docs/release-notes.md | 8 ++-- local/scripts/selfhost-shell.test.ts | 65 ++++++++++++++++++++++++++++ local/scripts/subboost.sh | 1 + 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 0bacfbc..a15cf83 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,7 +8,7 @@ SubBoost v2.5.0 主要改善代理组编辑、自部署更新和订阅生成稳 ### 主要变化 -- 移除单独的筛选代理组入口,相关功能转移到分流代理组高级模式和自定义分流组。 +- **移除筛选代理组**,相关功能转移到分流代理组高级模式和自定义分流组。 - 分流代理组高级模式支持按来源、地区、关键词和排除条件整理节点。 - 订阅生成更稳,规则顺序、代理组输出和常见 Mihomo 字段处理减少了意外变化。 - 节点导入兼容性更好,覆盖更多常见节点链接和 Mihomo YAML 配置。 @@ -22,7 +22,7 @@ SubBoost v2.5.0 主要改善代理组编辑、自部署更新和订阅生成稳 - 建议升级前备份 `/opt/subboost/.env` 和数据库,方便需要时回滚。 - 已安装 v2.4.0 的自部署实例可以继续使用 `subboost update` 更新。 - 普通订阅转换、模板和规则功能不需要手动改环境变量。 -- 现有筛选代理组会自动迁移到自定义代理组。如果你在 v2.4.0 使用过筛选代理组,请升级后打开自定义代理组检查;必要时可能需要重新配置。 +- 如果你在 v2.4.0 使用过筛选代理组,请升级后到自定义代理组或分流代理组高级模式里重新配置。 ## English @@ -32,7 +32,7 @@ SubBoost v2.5.0 mainly improves proxy group editing, self-hosted updates, and su ### Main Changes -- Removed the separate filtered proxy group entry point. Related features have moved to proxy group advanced mode and custom proxy groups. +- Removed filtered proxy groups. Related features have moved to proxy group advanced mode and custom proxy groups. - Proxy group advanced mode supports organizing nodes by source, region, keyword, and exclusion rules. - Made subscription generation more stable, reducing unexpected changes in rule order, proxy group output, and common Mihomo fields. - Improved node import compatibility for more common node links and Mihomo YAML configurations. @@ -46,4 +46,4 @@ SubBoost v2.5.0 mainly improves proxy group editing, self-hosted updates, and su - Back up `/opt/subboost/.env` and the database before upgrading so rollback is easier if needed. - Existing v2.4.0 self-hosted installations can continue to update with `subboost update`. - Normal subscription conversion, templates, and rules do not require manual environment-variable changes. -- Existing filtered proxy groups will migrate to custom proxy groups automatically. If you used filtered proxy groups in v2.4.0, open the custom proxy group editor after upgrading and check the result. You may need to reconfigure them if the output is not what you expect. +- If you used filtered proxy groups in v2.4.0, reconfigure them after upgrading through custom proxy groups or proxy group advanced mode. diff --git a/local/scripts/selfhost-shell.test.ts b/local/scripts/selfhost-shell.test.ts index ab2b70e..d9d8d25 100644 --- a/local/scripts/selfhost-shell.test.ts +++ b/local/scripts/selfhost-shell.test.ts @@ -150,6 +150,71 @@ ENV expect(result.stdout).toContain("Doctor: OK"); }); + it("loads SUBBOOST_PORT from .env before doctor health checks", () => { + const script = ` + set -Eeuo pipefail + home="$(mktemp -d)" + trap 'rm -rf "$home"' EXIT + cat > "$home/.env" <<'ENV' +SUBBOOST_IMAGE=image +POSTGRES_DB=subboost +POSTGRES_USER=subboost +POSTGRES_PASSWORD=password +DATABASE_URL=postgresql://subboost:password@db:5432/subboost?schema=public +ENCRYPTION_KEY=key +JWT_SECRET=jwt +CRON_SECRET=cron +APP_URL=http://127.0.0.1:31041 +SUBBOOST_PORT=31041 +ENV + : > "$home/docker-compose.yml" + export SUBBOOST_SCRIPT_SOURCE_ONLY=1 + export SUBBOOST_HOME="$home" + export SUBBOOST_DOCTOR_HEALTH_ATTEMPTS=1 + export SUBBOOST_DOCTOR_HEALTH_INTERVAL_SECONDS=0 + unset SUBBOOST_PORT APP_URL + source local/scripts/subboost.sh + docker() { + if [ "$1" = "info" ]; then return 0; fi + if [ "$1" = "compose" ]; then + case "$*" in + "compose version"*) return 0 ;; + *" config") return 0 ;; + *" ps -q app") printf 'app-id\\n'; return 0 ;; + *" ps -q db") printf 'db-id\\n'; return 0 ;; + *" ps -q cron") printf 'cron-id\\n'; return 0 ;; + esac + fi + if [ "$1" = "inspect" ]; then + case "$*" in + *".State.Status"*) printf 'running\\n'; return 0 ;; + *".State.Health"*) printf 'healthy\\n'; return 0 ;; + esac + fi + return 0 + } + curl_urls="$home/curl-urls" + : > "$curl_urls" + curl() { + printf '%s\\n' "$*" >> "$curl_urls" + case "$*" in + *"http://127.0.0.1:31041/api/health/"*) return 0 ;; + esac + return 1 + } + doctor_cmd + cat "$curl_urls" + `; + + const result = runBash(script); + + expect(result.status).toBe(0); + expect(result.stdout).toContain("Doctor: OK"); + expect(result.stdout).toContain("http://127.0.0.1:31041/api/health/live"); + expect(result.stdout).toContain("http://127.0.0.1:31041/api/health/ready"); + expect(result.stdout).not.toContain("http://127.0.0.1:3000/api/health"); + }); + it("waits for health before reporting update status", () => { const script = ` set -Eeuo pipefail diff --git a/local/scripts/subboost.sh b/local/scripts/subboost.sh index a172f85..6fd43b5 100644 --- a/local/scripts/subboost.sh +++ b/local/scripts/subboost.sh @@ -348,6 +348,7 @@ doctor_cmd() { [ -d "$SUBBOOST_HOME" ] || die "Missing $SUBBOOST_HOME" [ -f "$ENV_FILE" ] || die "Missing $ENV_FILE" [ -f "$COMPOSE_FILE" ] || die "Missing $COMPOSE_FILE" + load_env for key in SUBBOOST_IMAGE POSTGRES_DB POSTGRES_USER POSTGRES_PASSWORD DATABASE_URL ENCRYPTION_KEY JWT_SECRET CRON_SECRET APP_URL SUBBOOST_PORT; do grep -q "^$key=" "$ENV_FILE" || die "Missing $key in $ENV_FILE" done