fix: 受控升级 PK01 Sub2API 至 0.1.153
This commit is contained in:
@@ -82,7 +82,7 @@ targets:
|
||||
redisReplicas: 1
|
||||
image:
|
||||
repository: docker.1panel.live/weishaw/sub2api
|
||||
tag: 0.1.149
|
||||
tag: 0.1.153
|
||||
pullPolicy: IfNotPresent
|
||||
dependencyImages:
|
||||
redis: docker.m.daocloud.io/library/redis:8-alpine
|
||||
|
||||
@@ -262,6 +262,8 @@ install_out="$tmp/install.out"
|
||||
install_err="$tmp/install.err"
|
||||
pull_out="$tmp/pull.out"
|
||||
pull_err="$tmp/pull.err"
|
||||
legacy_out="$tmp/legacy.out"
|
||||
legacy_err="$tmp/legacy.err"
|
||||
up_out="$tmp/up.out"
|
||||
up_err="$tmp/up.err"
|
||||
health_out="$tmp/health.out"
|
||||
@@ -400,9 +402,37 @@ else
|
||||
fi
|
||||
if [ "$pull_rc" -eq 0 ]; then
|
||||
if [ -n "$compose_cmd" ]; then
|
||||
$compose_cmd -p ${shQuote(host.projectName)} -f ${shQuote(host.composePath)} up -d --remove-orphans >"$up_out" 2>"$up_err"
|
||||
up_rc=$?
|
||||
legacy_rc=0
|
||||
: >"$legacy_out"
|
||||
: >"$legacy_err"
|
||||
for container_name in ${shQuote(`${host.projectName}-app`)} ${shQuote(`${host.projectName}-redis`)}; do
|
||||
if $docker_bin inspect "$container_name" >/dev/null 2>&1; then
|
||||
compose_project="$($docker_bin inspect -f '{{ index .Config.Labels "com.docker.compose.project" }}' "$container_name" 2>/dev/null || true)"
|
||||
if [ "$compose_project" != ${shQuote(host.projectName)} ]; then
|
||||
if $docker_bin rm -f "$container_name" >>"$legacy_out" 2>>"$legacy_err"; then
|
||||
printf 'removed legacy container name=%s\\n' "$container_name" >>"$legacy_out"
|
||||
else
|
||||
legacy_rc=1
|
||||
fi
|
||||
else
|
||||
printf 'kept compose container name=%s project=%s\\n' "$container_name" "$compose_project" >>"$legacy_out"
|
||||
fi
|
||||
else
|
||||
printf 'container absent name=%s\\n' "$container_name" >>"$legacy_out"
|
||||
fi
|
||||
done
|
||||
if [ "$legacy_rc" -eq 0 ]; then
|
||||
$compose_cmd -p ${shQuote(host.projectName)} -f ${shQuote(host.composePath)} up -d --remove-orphans >"$up_out" 2>"$up_err"
|
||||
up_rc=$?
|
||||
else
|
||||
: >"$up_out"
|
||||
printf '%s\\n' 'skipped because legacy container takeover failed' >"$up_err"
|
||||
up_rc=1
|
||||
fi
|
||||
else
|
||||
legacy_rc=0
|
||||
printf '%s\\n' 'not-applicable raw-docker mode' >"$legacy_out"
|
||||
: >"$legacy_err"
|
||||
$docker_bin rm -f ${shQuote(`${host.projectName}-app`)} ${shQuote(`${host.projectName}-redis`)} >"$up_out" 2>"$up_err" || true
|
||||
$docker_bin run -d --name ${shQuote(`${host.projectName}-redis`)} \\
|
||||
--restart unless-stopped \\
|
||||
@@ -424,6 +454,9 @@ if [ "$pull_rc" -eq 0 ]; then
|
||||
if [ "$redis_run_rc" -eq 0 ] && [ "$app_run_rc" -eq 0 ]; then up_rc=0; else up_rc=1; fi
|
||||
fi
|
||||
else
|
||||
: >"$legacy_out"
|
||||
printf '%s\\n' 'skipped because pull failed' >"$legacy_err"
|
||||
legacy_rc=1
|
||||
: >"$up_out"
|
||||
printf '%s\\n' 'skipped because pull failed' >"$up_err"
|
||||
up_rc=1
|
||||
@@ -442,13 +475,13 @@ else
|
||||
: >"$health_out"
|
||||
printf '%s\\n' 'skipped because compose up failed' >"$health_err"
|
||||
fi
|
||||
python3 - "$docker_rc" "$preserve_rc" "$install_rc" "$pull_rc" "$up_rc" "$health_rc" "$compose_mode" "$docker_out" "$docker_err" "$preserve_out" "$preserve_err" "$install_out" "$install_err" "$pull_out" "$pull_err" "$up_out" "$up_err" "$health_out" "$health_err" <<'PY'
|
||||
python3 - "$docker_rc" "$preserve_rc" "$install_rc" "$pull_rc" "$legacy_rc" "$up_rc" "$health_rc" "$compose_mode" "$docker_out" "$docker_err" "$preserve_out" "$preserve_err" "$install_out" "$install_err" "$pull_out" "$pull_err" "$legacy_out" "$legacy_err" "$up_out" "$up_err" "$health_out" "$health_err" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
|
||||
docker_rc, preserve_rc, install_rc, pull_rc, up_rc, health_rc = [int(value) for value in sys.argv[1:7]]
|
||||
docker_mode = sys.argv[7]
|
||||
paths = sys.argv[8:]
|
||||
docker_rc, preserve_rc, install_rc, pull_rc, legacy_rc, up_rc, health_rc = [int(value) for value in sys.argv[1:8]]
|
||||
docker_mode = sys.argv[8]
|
||||
paths = sys.argv[9:]
|
||||
|
||||
def text(path, limit=4000):
|
||||
try:
|
||||
@@ -463,7 +496,7 @@ def parsed(path):
|
||||
return None
|
||||
|
||||
payload = {
|
||||
"ok": docker_rc == 0 and preserve_rc == 0 and install_rc == 0 and pull_rc == 0 and up_rc == 0 and health_rc == 0,
|
||||
"ok": docker_rc == 0 and preserve_rc == 0 and install_rc == 0 and pull_rc == 0 and legacy_rc == 0 and up_rc == 0 and health_rc == 0,
|
||||
"target": "${target.id}",
|
||||
"runtimeMode": "host-docker",
|
||||
"route": "${target.route}",
|
||||
@@ -483,8 +516,9 @@ payload = {
|
||||
"preserveEnv": {"exitCode": preserve_rc, "summary": parsed(paths[2]), "stdout": text(paths[2]), "stderr": text(paths[3])},
|
||||
"installFiles": {"exitCode": install_rc, "stdout": text(paths[4]), "stderr": text(paths[5])},
|
||||
"pull": {"exitCode": pull_rc, "stdout": text(paths[6]), "stderr": text(paths[7])},
|
||||
"composeUp": {"exitCode": up_rc, "stdout": text(paths[8]), "stderr": text(paths[9])},
|
||||
"localHealth": {"exitCode": health_rc, "stdout": text(paths[10]), "stderr": text(paths[11])},
|
||||
"legacyTakeover": {"exitCode": legacy_rc, "stdout": text(paths[8]), "stderr": text(paths[9])},
|
||||
"composeUp": {"exitCode": up_rc, "stdout": text(paths[10]), "stderr": text(paths[11])},
|
||||
"localHealth": {"exitCode": health_rc, "stdout": text(paths[12]), "stderr": text(paths[13])},
|
||||
},
|
||||
"valuesPrinted": False,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user