From 6b829331c3fa82177d62b13e49883cdc5150b285 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Mon, 16 Jun 2025 14:35:48 +0300 Subject: [PATCH] Features: 1) Split `docker compose build` and `docker compose up -d` into distinct steps with updated messages; 2) Replace custom spinner in Unix script with simplified `run_cmd` approach; Fixes: 1) Update final output message to align with application name (`eVibes`); Extra: 1) Remove redundant spinner implementation in Unix script for clarity and reduction of complexity; 2) General script cleanup and minor formatting tweaks. --- scripts/Unix/reboot.sh | 79 +++++++++++++------------------------- scripts/Windows/reboot.ps1 | 8 ++-- 2 files changed, 32 insertions(+), 55 deletions(-) diff --git a/scripts/Unix/reboot.sh b/scripts/Unix/reboot.sh index 3d5a307d..39b8b659 100755 --- a/scripts/Unix/reboot.sh +++ b/scripts/Unix/reboot.sh @@ -1,60 +1,35 @@ #!/usr/bin/env bash set -euo pipefail -SPINNER=('|' '/' '-' '\') -COLORS=(97 37) -DELAY=0.1 - -hide_cursor() { tput civis 2>/dev/null || true; } -show_cursor() { tput cnorm 2>/dev/null || true; } - -spinner() { - local pid=$1 msg=$2 i=0 frame color - hide_cursor - while kill -0 "$pid" 2>/dev/null; do - frame="${SPINNER[i % ${#SPINNER[@]}]}" - color="${COLORS[i % ${#COLORS[@]}]}" - printf "\r\e[36m%s... \e[0m\e[%sm%s\e[0m" "$msg" "$color" "$frame" - ((i++)) - sleep "$DELAY" - done - show_cursor -} - -run_with_spinner() { - local cmd="$1" msg="$2" rc=0 - - printf "\e[36m%s... \e[0m" "$msg" - - bash -c "$cmd" &> /dev/null & - local pid=$! - - spinner "$pid" "$msg" - - if ! wait "$pid"; then rc=$?; fi - - if [[ $rc -eq 0 ]]; then - printf "\r\e[32m✔\e[0m %s\n" "$msg" - else - printf "\r\e[33m✖ (exit %d)\e[0m %s\n" "$rc" "$msg" - fi +run_cmd() { + local msg=$1; shift + printf "%s... " "$msg" + "$@" + printf "OK\n" } echo -run_with_spinner "docker compose --ansi never down || true" \ - "Stopping services" -run_with_spinner "docker compose --ansi never build" \ - "Rebuilding services" -run_with_spinner "docker compose --ansi never up -d" \ - "Starting services" -run_with_spinner "docker compose --ansi never exec app poetry run python manage.py migrate --no-input" \ - "Applying database migrations" -run_with_spinner "docker compose --ansi never exec app poetry run python manage.py collectstatic --no-input" \ - "Collecting static files" -run_with_spinner "docker compose --ansi never exec app poetry run python manage.py set_default_caches" \ - "Setting default caches" -run_with_spinner "docker system prune -f" \ - "Cleaning up unused Docker data" +run_cmd "Stopping services (down)" \ + docker compose down -echo -e "\n\e[1mAll done! eVibes is up and running.\e[0m" +run_cmd "Rebuilding services" \ + docker compose build + +run_cmd "Starting services" \ + docker compose up -d + +run_cmd "Applying database migrations" \ + docker compose exec app poetry run python manage.py migrate --no-input + +run_cmd "Collecting static files" \ + docker compose exec app poetry run python manage.py collectstatic --no-input + +run_cmd "Setting default caches" \ + docker compose exec app poetry run python manage.py set_default_caches + +run_cmd "Cleaning up unused Docker data" \ + docker system prune -f + +echo +echo "All done! eVibes is up and running." diff --git a/scripts/Windows/reboot.ps1 b/scripts/Windows/reboot.ps1 index 915b44fa..7be8b1a5 100644 --- a/scripts/Windows/reboot.ps1 +++ b/scripts/Windows/reboot.ps1 @@ -44,8 +44,10 @@ function Invoke-Spinner Write-Host "" Invoke-Spinner -Arguments "compose down" ` -Message "Stopping services (down)" -Invoke-Spinner -Arguments "compose up -d --build" ` - -Message "Rebuilding & starting services" +Invoke-Spinner -Arguments "compose build" ` + -Message "Rebuilding services" +Invoke-Spinner -Arguments "compose up -d" ` + -Message "Starting services" Invoke-Spinner -Arguments "compose exec app poetry run python manage.py migrate --no-input" ` -Message "Applying database migrations" Invoke-Spinner -Arguments "compose exec app poetry run python manage.py collectstatic --no-input" ` @@ -55,4 +57,4 @@ Invoke-Spinner -Arguments "compose exec app poetry run python manage.py set_defa Invoke-Spinner -Arguments "system prune -f" ` -Message "Cleaning up unused Docker data" -Write-Host "`nAll done! Your application is up and running." -ForegroundColor White +Write-Host "`nAll done! eVibes is up and running." -ForegroundColor White