修改config

This commit is contained in:
2025-12-09 13:59:03 +08:00
parent 5e68d97127
commit 1890a8380b
4 changed files with 108 additions and 23 deletions
+25
View File
@@ -0,0 +1,25 @@
param(
[string]$RepoUrl = "",
[string]$Branch = "main",
[string]$RepoDir = ".",
[string]$ComposeFile = "docker-compose.yml",
[string]$BaseUrl = "http://localhost:57778",
[string]$AdminToken = ""
)
if (!(Test-Path $RepoDir)) { New-Item -ItemType Directory -Path $RepoDir | Out-Null }
if (!(Test-Path (Join-Path $RepoDir ".git"))) {
if ($RepoUrl -eq "") { throw "RepoUrl is required for clone" }
git clone -b $Branch $RepoUrl $RepoDir
}
Set-Location $RepoDir
git remote set-url origin $RepoUrl
git fetch origin
git checkout $Branch
git pull origin $Branch
if (!(Test-Path $ComposeFile)) { throw "compose not found: $ComposeFile" }
docker compose -f $ComposeFile up -d --build
$headers = @{}
if ($AdminToken -ne "") { $headers["X-Admin-Token"] = $AdminToken }
try { Invoke-RestMethod -Method Post -Uri "$BaseUrl/api/admin/reload_cutoff" -Headers $headers | Out-Null } catch { }
try { Invoke-RestMethod -Method Get -Uri "$BaseUrl/api/metrics" | ConvertTo-Json -Depth 3 | Write-Output } catch { }
try { Invoke-RestMethod -Method Post -Uri "$BaseUrl/api/admin/test_push" -Headers $headers | ConvertTo-Json -Depth 3 | Write-Output } catch { }
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
REPO_URL=${1:-}
BRANCH=${2:-main}
REPO_DIR=${3:-.}
COMPOSE_FILE=${4:-docker-compose.yml}
BASE_URL=${5:-http://localhost:57778}
ADMIN_TOKEN=${6:-}
mkdir -p "$REPO_DIR"
if [ ! -d "$REPO_DIR/.git" ]; then
[ -z "$REPO_URL" ] && { echo "RepoUrl required"; exit 1; }
git clone -b "$BRANCH" "$REPO_URL" "$REPO_DIR"
fi
cd "$REPO_DIR"
git remote set-url origin "$REPO_URL"
git fetch origin
git checkout "$BRANCH"
git pull origin "$BRANCH"
[ -f "$COMPOSE_FILE" ] || { echo "compose not found: $COMPOSE_FILE"; exit 1; }
docker compose -f "$COMPOSE_FILE" up -d --build
HDR=( )
if [ -n "$ADMIN_TOKEN" ]; then HDR=( -H "X-Admin-Token: $ADMIN_TOKEN" ); fi
curl -s -X POST "${BASE_URL}/api/admin/reload_cutoff" "${HDR[@]}" || true
curl -s "${BASE_URL}/api/metrics" || true
curl -s -X POST "${BASE_URL}/api/admin/test_push" "${HDR[@]}" || true