schon/scripts/Windows/reboot.ps1
Egor fureunoir Gorbunov 6b829331c3 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.
2025-06-16 14:35:48 +03:00

60 lines
2 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$Spinner = @('|', '/', '-', '\')
$Colors = @('White', 'Gray')
$Delay = 100
function Invoke-Spinner
{
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$Arguments,
[Parameter(Mandatory)]
[string]$Message
)
Write-Host -NoNewLine -ForegroundColor Cyan ("{0}... " -f $Message)
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = "docker"
$startInfo.Arguments = $Arguments + " --ansi never"
$startInfo.RedirectStandardOutput = $true
$startInfo.RedirectStandardError = $true
$startInfo.UseShellExecute = $false
$proc = [System.Diagnostics.Process]::Start($startInfo)
$i = 0
while (-not $proc.HasExited)
{
$frame = $Spinner[$i % $Spinner.Length]
$color = $Colors[$i % $Colors.Length]
Write-Host -NoNewLine -ForegroundColor $color $frame
Start-Sleep -Milliseconds $Delay
Write-Host -NoNewLine "`b"
$i++
}
$proc.WaitForExit()
Write-Host -ForegroundColor Green ""
}
Write-Host ""
Invoke-Spinner -Arguments "compose down" `
-Message "Stopping services (down)"
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" `
-Message "Collecting static files"
Invoke-Spinner -Arguments "compose exec app poetry run python manage.py set_default_caches" `
-Message "Setting default caches"
Invoke-Spinner -Arguments "system prune -f" `
-Message "Cleaning up unused Docker data"
Write-Host "`nAll done! eVibes is up and running." -ForegroundColor White