fix(deploy): auto-remove legacy Compose MySQL containers on upgrade
Run uninstall-mysql-compose before install/upgrade and pass --remove-orphans so nexus-prod mysql orphans are stopped after the service is dropped from compose. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+18
-3
@@ -537,12 +537,26 @@ write_env_prod() {
|
||||
info "已写入 $env_file"
|
||||
}
|
||||
|
||||
purge_legacy_bundled_services() {
|
||||
local root="$1"
|
||||
local s
|
||||
for s in \
|
||||
"$root/deploy/uninstall-mysql-compose.sh" \
|
||||
"$root/deploy/uninstall-redis-compose.sh"; do
|
||||
if [[ -x "$s" ]]; then
|
||||
step "清理遗留 Compose 内置服务: $(basename "$s")"
|
||||
NEXUS_ROOT="$root" bash "$s" || true
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
compose_up() {
|
||||
local root="$1"
|
||||
save_host_profile "$root"
|
||||
purge_legacy_bundled_services "$root"
|
||||
info "档位: ${NEXUS_PROFILE}(仅 Nexus 容器;MySQL/Redis 请自行安装)"
|
||||
info "构建并启动(首次约 10~20 分钟)..."
|
||||
compose_cmd "$root" up -d --build
|
||||
compose_cmd "$root" up -d --build --remove-orphans
|
||||
}
|
||||
|
||||
verify_install_wizard() {
|
||||
@@ -772,8 +786,9 @@ cmd_upgrade() {
|
||||
git_upgrade
|
||||
apply_pool_to_env_prod "$NEXUS_ROOT" "$(profile_env_file "$NEXUS_ROOT")"
|
||||
save_host_profile "$NEXUS_ROOT"
|
||||
step "重建容器..."
|
||||
compose_cmd "$NEXUS_ROOT" up -d --build
|
||||
purge_legacy_bundled_services "$NEXUS_ROOT"
|
||||
step "重建容器(--remove-orphans 清理旧 mysql/redis)..."
|
||||
compose_cmd "$NEXUS_ROOT" up -d --build --remove-orphans
|
||||
if [[ "$PRUNE_IMAGES" == true ]]; then
|
||||
docker image prune -f >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user