diff --git a/scripts/deploy-community.sh b/scripts/deploy-community.sh index 2ad1cd8..a9129cd 100755 --- a/scripts/deploy-community.sh +++ b/scripts/deploy-community.sh @@ -26,11 +26,6 @@ compose_profiles="" if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then compose_profiles="--profile cache" fi -postgres_scale="" -if [ "$(env_value POSTGRES_HOST postgres)" != "postgres" ]; then - postgres_scale="--scale postgres=0" -fi - compose() { # Intentional word splitting: compose_profiles is either empty or two arguments. # shellcheck disable=SC2086 @@ -38,11 +33,21 @@ compose() { } compose_up() { + postgres_scale="" + if [ "$(env_value POSTGRES_HOST postgres)" != "postgres" ] \ + && compose config --services | grep -Fxq postgres; then + postgres_scale="--scale postgres=0" + fi # Intentional word splitting: postgres_scale is either empty or two arguments. # shellcheck disable=SC2086 compose up -d --remove-orphans $postgres_scale } +show_failure_diagnostics() { + compose ps >&2 || true + compose logs --no-color migrate >&2 || true +} + wait_for_stack() { readiness_path="$1" attempt=1 @@ -129,10 +134,6 @@ rollback() { if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then compose_profiles="--profile cache" fi - postgres_scale="" - if [ "$(env_value POSTGRES_HOST postgres)" != "postgres" ]; then - postgres_scale="--scale postgres=0" - fi compose_up wait_for_stack health } @@ -142,7 +143,7 @@ create_backup compose pull if ! compose_up || ! wait_for_stack ready; then - compose ps >&2 || true + show_failure_diagnostics rollback exit 1 fi diff --git a/scripts/restore-community.sh b/scripts/restore-community.sh index 0eea251..2065479 100755 --- a/scripts/restore-community.sh +++ b/scripts/restore-community.sh @@ -28,15 +28,16 @@ compose_profiles="" if [ "$cache_backend" = "valkey" ] || [ "$cache_backend" = "redis" ]; then compose_profiles="--profile cache" fi -postgres_scale="" -if [ "$(env_value POSTGRES_HOST postgres)" != "postgres" ]; then - postgres_scale="--scale postgres=0" -fi compose() { # shellcheck disable=SC2086 docker compose $compose_profiles "$@" } compose_up() { + postgres_scale="" + if [ "$(env_value POSTGRES_HOST postgres)" != "postgres" ] \ + && compose config --services | grep -Fxq postgres; then + postgres_scale="--scale postgres=0" + fi # shellcheck disable=SC2086 compose up -d --remove-orphans $postgres_scale }