Files
btgo-playwright/deployment/windows/scripts/start_service.ps1
2025-11-06 20:55:35 +02:00

66 lines
1.8 KiB
PowerShell

#Requires -RunAsAdministrator
<#
.SYNOPSIS
BTGO Telegram Bot - Start Service Script
.DESCRIPTION
Pornește serviciul Windows
#>
$ErrorActionPreference = "Stop"
$ServiceName = "BTGOTelegramBot"
function Write-ColorOutput {
param([string]$Message, [string]$Prefix = "")
$color = switch ($Prefix) {
"[OK]" { "Green" }
"[INFO]" { "Cyan" }
"[EROARE]" { "Red" }
default { "White" }
}
if ($Prefix) {
Write-Host "$Prefix " -ForegroundColor $color -NoNewline
Write-Host $Message
} else {
Write-Host $Message
}
}
Write-Host ""
Write-Host ("=" * 80) -ForegroundColor Cyan
Write-Host "START SERVICIU: $ServiceName" -ForegroundColor Yellow
Write-Host ("=" * 80) -ForegroundColor Cyan
Write-Host ""
# Verifică dacă serviciul există
$service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if (-not $service) {
Write-ColorOutput "Serviciul $ServiceName nu este instalat!" -Prefix "[EROARE]"
Read-Host "`nApasa Enter pentru a inchide"
exit 1
}
# Pornește serviciul
Write-ColorOutput "Pornire serviciu..." -Prefix "[INFO]"
try {
Start-Service -Name $ServiceName
Write-ColorOutput "Serviciu pornit cu succes!" -Prefix "[OK]"
Start-Sleep -Seconds 2
# Verifică status
$service = Get-Service -Name $ServiceName
Write-Host ""
Get-Service -Name $ServiceName | Format-Table -AutoSize
} catch {
Write-ColorOutput "Pornirea serviciului a esuat!" -Prefix "[EROARE]"
Write-Host "Eroare: $_" -ForegroundColor Red
Write-Host ""
Write-Host "Verificati logurile:" -ForegroundColor Yellow
Write-Host " Get-Content logs\telegram_bot_stderr.log"
Read-Host "`nApasa Enter pentru a inchide"
exit 1
}
Read-Host "`nApasa Enter pentru a inchide"