|
| 1 | +# Task Management System - Запуск проекта |
| 2 | +# Для остановки нажмите любую клавишу |
| 3 | + |
| 4 | +$Host.UI.RawUI.WindowTitle = "Task Management System" |
| 5 | +$ErrorActionPreference = "SilentlyContinue" |
| 6 | + |
| 7 | +# Переход в директорию проекта |
| 8 | +Set-Location $PSScriptRoot |
| 9 | + |
| 10 | +Write-Host "╔══════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan |
| 11 | +Write-Host "║ TASK MANAGEMENT SYSTEM - ЗАПУСК ПРОЕКТА ║" -ForegroundColor Cyan |
| 12 | +Write-Host "╚══════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan |
| 13 | +Write-Host "" |
| 14 | + |
| 15 | +# Остановка предыдущих процессов на портах |
| 16 | +Write-Host "[0/5] Остановка предыдущих процессов..." -ForegroundColor Yellow |
| 17 | +foreach ($port in @(8080, 8081, 8082)) { |
| 18 | + $connections = netstat -ano | Select-String ":$port.*LISTENING" |
| 19 | + foreach ($conn in $connections) { |
| 20 | + $processId = ($conn -split '\s+')[-1] |
| 21 | + if ($processId -match '^\d+$') { |
| 22 | + Write-Host "Останавливаю процесс на порту $port, PID: $processId" |
| 23 | + Stop-Process -Id $processId -Force -ErrorAction SilentlyContinue |
| 24 | + } |
| 25 | + } |
| 26 | +} |
| 27 | +Start-Sleep -Seconds 3 |
| 28 | +Write-Host "[OK] Порты освобождены" -ForegroundColor Green |
| 29 | +Write-Host "" |
| 30 | + |
| 31 | +# Настройка Java 17 |
| 32 | +$env:JAVA_HOME = "C:\Program Files\Eclipse Adoptium\jdk-17.0.17.10-hotspot" |
| 33 | +$env:PATH = "$env:JAVA_HOME\bin;$env:PATH" |
| 34 | +Write-Host "[INFO] Используется Java 17" -ForegroundColor Cyan |
| 35 | + |
| 36 | +# Проверка Java |
| 37 | +Write-Host "[1/5] Проверка Java..." -ForegroundColor Yellow |
| 38 | +$null = java -version 2>&1 |
| 39 | +if ($LASTEXITCODE -ne 0) { |
| 40 | + Write-Host "[ОШИБКА] Java не найдена" -ForegroundColor Red |
| 41 | + Read-Host "Нажмите Enter для выхода" |
| 42 | + exit 1 |
| 43 | +} |
| 44 | +Write-Host "[OK] Java найдена" -ForegroundColor Green |
| 45 | +Write-Host "" |
| 46 | + |
| 47 | +# Проверка Docker |
| 48 | +Write-Host "[2/5] Проверка Docker..." -ForegroundColor Yellow |
| 49 | +docker info 2>&1 | Out-Null |
| 50 | +if ($LASTEXITCODE -ne 0) { |
| 51 | + Write-Host "[ОШИБКА] Docker не запущен. Запустите Docker Desktop." -ForegroundColor Red |
| 52 | + Read-Host "Нажмите Enter для выхода" |
| 53 | + exit 1 |
| 54 | +} |
| 55 | +Write-Host "[OK] Docker запущен" -ForegroundColor Green |
| 56 | +Write-Host "" |
| 57 | + |
| 58 | +# Сборка сервисов |
| 59 | +Write-Host "[3/5] Сборка сервисов и пересборка Docker образов..." -ForegroundColor Yellow |
| 60 | +mvn -q clean package -pl auth-service,task-service -DskipTests 2>&1 | Out-Null |
| 61 | +if ($LASTEXITCODE -ne 0) { |
| 62 | + Write-Host "[ОШИБКА] Не удалось собрать сервисы" -ForegroundColor Red |
| 63 | + Read-Host "Нажмите Enter для выхода" |
| 64 | + exit 1 |
| 65 | +} |
| 66 | +docker-compose build --no-cache auth-service task-service 2>&1 | Out-Null |
| 67 | +Write-Host "[OK] Образы пересобраны" -ForegroundColor Green |
| 68 | +Write-Host "" |
| 69 | + |
| 70 | +# Запуск инфраструктуры |
| 71 | +Write-Host "[4/5] Запуск инфраструктуры Docker..." -ForegroundColor Yellow |
| 72 | +docker-compose up -d |
| 73 | +if ($LASTEXITCODE -ne 0) { |
| 74 | + Write-Host "[ОШИБКА] Не удалось запустить контейнеры" -ForegroundColor Red |
| 75 | + Read-Host "Нажмите Enter для выхода" |
| 76 | + exit 1 |
| 77 | +} |
| 78 | +Write-Host "[OK] Контейнеры запущены" -ForegroundColor Green |
| 79 | +Write-Host "" |
| 80 | + |
| 81 | +# Ожидание готовности |
| 82 | +Write-Host "[5/5] Ожидание готовности сервисов (40 сек)..." -ForegroundColor Yellow |
| 83 | +Start-Sleep -Seconds 40 |
| 84 | +Write-Host "[OK] Сервисы запущены" -ForegroundColor Green |
| 85 | +Write-Host "" |
| 86 | + |
| 87 | +Write-Host "╔══════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan |
| 88 | +Write-Host "║ TASK MANAGEMENT SYSTEM ЗАПУЩЕН ║" -ForegroundColor Cyan |
| 89 | +Write-Host "╠══════════════════════════════════════════════════════════════╣" -ForegroundColor Cyan |
| 90 | +Write-Host "║ Сервисы (запущены в Docker): ║" -ForegroundColor Cyan |
| 91 | +Write-Host "║ - Auth Service: http://localhost:8081 ║" -ForegroundColor Cyan |
| 92 | +Write-Host "║ - Task Service: http://localhost:8082 ║" -ForegroundColor Cyan |
| 93 | +Write-Host "║ - API Gateway: http://localhost:8080 ║" -ForegroundColor Cyan |
| 94 | +Write-Host "╠══════════════════════════════════════════════════════════════╣" -ForegroundColor Cyan |
| 95 | +Write-Host "║ Swagger UI: ║" -ForegroundColor Cyan |
| 96 | +Write-Host "║ - Auth Swagger: http://localhost:8081/swagger-ui.html ║" -ForegroundColor Cyan |
| 97 | +Write-Host "║ - Task Swagger: http://localhost:8082/swagger-ui.html ║" -ForegroundColor Cyan |
| 98 | +Write-Host "╠══════════════════════════════════════════════════════════════╣" -ForegroundColor Cyan |
| 99 | +Write-Host "║ Мониторинг: ║" -ForegroundColor Cyan |
| 100 | +Write-Host "║ - Prometheus: http://localhost:9090 ║" -ForegroundColor Cyan |
| 101 | +Write-Host "║ - Grafana: http://localhost:3000 (admin/admin) ║" -ForegroundColor Cyan |
| 102 | +Write-Host "║ - Kibana: http://localhost:5601 ║" -ForegroundColor Cyan |
| 103 | +Write-Host "╠══════════════════════════════════════════════════════════════╣" -ForegroundColor Cyan |
| 104 | +Write-Host "║ Для остановки: нажмите любую клавишу ║" -ForegroundColor Cyan |
| 105 | +Write-Host "╚══════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan |
| 106 | +Write-Host "" |
| 107 | + |
| 108 | +# Открытие браузера |
| 109 | +Start-Process "http://localhost:8081/swagger-ui.html" |
| 110 | +Start-Sleep -Seconds 1 |
| 111 | +Start-Process "http://localhost:8082/swagger-ui.html" |
| 112 | +Start-Sleep -Seconds 1 |
| 113 | +Start-Process "http://localhost:9090" |
| 114 | +Start-Sleep -Seconds 1 |
| 115 | +Start-Process "http://localhost:3000" |
| 116 | +Start-Sleep -Seconds 1 |
| 117 | +Start-Process "http://localhost:5601" |
| 118 | + |
| 119 | +# Ожидание нажатия клавиши |
| 120 | +Write-Host "" |
| 121 | +Write-Host "Нажмите любую клавишу для остановки сервисов..." -ForegroundColor Yellow |
| 122 | +$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") |
| 123 | + |
| 124 | +# Cleanup |
| 125 | +Write-Host "" |
| 126 | +Write-Host "╔══════════════════════════════════════════════════════════════╗" -ForegroundColor Yellow |
| 127 | +Write-Host "║ ОСТАНОВКА СЕРВИСОВ... ║" -ForegroundColor Yellow |
| 128 | +Write-Host "╚══════════════════════════════════════════════════════════════╝" -ForegroundColor Yellow |
| 129 | +Write-Host "" |
| 130 | +Write-Host "Остановка контейнеров Docker..." -ForegroundColor Yellow |
| 131 | +Set-Location $PSScriptRoot |
| 132 | +docker-compose down |
| 133 | +Write-Host "" |
| 134 | +Write-Host "╔══════════════════════════════════════════════════════════════╗" -ForegroundColor Green |
| 135 | +Write-Host "║ ВСЕ СЕРВИСЫ ОСТАНОВЛЕНЫ ║" -ForegroundColor Green |
| 136 | +Write-Host "╚══════════════════════════════════════════════════════════════╝" -ForegroundColor Green |
| 137 | +Write-Host "" |
| 138 | +Write-Host "Нажмите Enter для закрытия окна..." |
| 139 | +Read-Host |
0 commit comments