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.
This commit is contained in:
parent
979e7fdac1
commit
6b829331c3
2 changed files with 32 additions and 55 deletions
|
|
@ -1,60 +1,35 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SPINNER=('|' '/' '-' '\')
|
run_cmd() {
|
||||||
COLORS=(97 37)
|
local msg=$1; shift
|
||||||
DELAY=0.1
|
printf "%s... " "$msg"
|
||||||
|
"$@"
|
||||||
hide_cursor() { tput civis 2>/dev/null || true; }
|
printf "OK\n"
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
run_with_spinner "docker compose --ansi never down || true" \
|
run_cmd "Stopping services (down)" \
|
||||||
"Stopping services"
|
docker compose down
|
||||||
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"
|
|
||||||
|
|
||||||
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."
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,10 @@ function Invoke-Spinner
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Invoke-Spinner -Arguments "compose down" `
|
Invoke-Spinner -Arguments "compose down" `
|
||||||
-Message "Stopping services (down)"
|
-Message "Stopping services (down)"
|
||||||
Invoke-Spinner -Arguments "compose up -d --build" `
|
Invoke-Spinner -Arguments "compose build" `
|
||||||
-Message "Rebuilding & starting services"
|
-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" `
|
Invoke-Spinner -Arguments "compose exec app poetry run python manage.py migrate --no-input" `
|
||||||
-Message "Applying database migrations"
|
-Message "Applying database migrations"
|
||||||
Invoke-Spinner -Arguments "compose exec app poetry run python manage.py collectstatic --no-input" `
|
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" `
|
Invoke-Spinner -Arguments "system prune -f" `
|
||||||
-Message "Cleaning up unused Docker data"
|
-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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue