initializare
This commit is contained in:
101
deployment/windows/scripts/status.ps1
Normal file
101
deployment/windows/scripts/status.ps1
Normal file
@@ -0,0 +1,101 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
BTGO Telegram Bot - Service Status Script
|
||||
.DESCRIPTION
|
||||
Afiseaza status detaliat al serviciului
|
||||
#>
|
||||
|
||||
$ServiceName = "BTGOTelegramBot"
|
||||
$ScriptDir = Split-Path -Parent $PSCommandPath
|
||||
$ProjectDir = Resolve-Path (Join-Path $ScriptDir "..\..\..") | Select-Object -ExpandProperty Path
|
||||
$LogDir = Join-Path $ProjectDir "logs"
|
||||
|
||||
function Write-ColorOutput {
|
||||
param([string]$Message, [string]$Prefix = "")
|
||||
$color = switch ($Prefix) {
|
||||
"[OK]" { "Green" }
|
||||
"[INFO]" { "Cyan" }
|
||||
"[AVERTIZARE]" { "Yellow" }
|
||||
default { "White" }
|
||||
}
|
||||
if ($Prefix) {
|
||||
Write-Host "$Prefix " -ForegroundColor $color -NoNewline
|
||||
Write-Host $Message
|
||||
} else {
|
||||
Write-Host $Message -ForegroundColor $color
|
||||
}
|
||||
}
|
||||
|
||||
function Write-Separator {
|
||||
param([string]$Title)
|
||||
Write-Host ""
|
||||
Write-Host ("=" * 80) -ForegroundColor Cyan
|
||||
Write-Host $Title -ForegroundColor Yellow
|
||||
Write-Host ("=" * 80) -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Write-Separator "BTGO TELEGRAM BOT - STATUS SERVICIU"
|
||||
|
||||
# Verifică dacă serviciul există
|
||||
$service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
|
||||
if (-not $service) {
|
||||
Write-ColorOutput "Serviciul $ServiceName NU este instalat" -Prefix "[INFO]"
|
||||
Write-Host ""
|
||||
Write-Host "Pentru instalare, rulati:" -ForegroundColor Yellow
|
||||
Write-Host " .\deploy.ps1"
|
||||
Write-Host ""
|
||||
Read-Host "Apasa Enter pentru a inchide"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Afișează informații serviciu
|
||||
Write-Host "[STATUS SERVICIU]" -ForegroundColor Yellow
|
||||
$service | Format-Table -Property Status, Name, DisplayName, StartType -AutoSize
|
||||
|
||||
# Afișează configurație detaliată
|
||||
Write-Host "[CONFIGURATIE SERVICIU]" -ForegroundColor Yellow
|
||||
Get-WmiObject -Class Win32_Service -Filter "Name='$ServiceName'" |
|
||||
Format-List Name, DisplayName, State, StartMode, PathName
|
||||
|
||||
# Verifică ultimele logs
|
||||
$stdoutLog = Join-Path $LogDir "telegram_bot_stdout.log"
|
||||
if (Test-Path $stdoutLog) {
|
||||
Write-Host "[ULTIMELE 10 LINII DIN LOG]" -ForegroundColor Yellow
|
||||
Get-Content $stdoutLog -Tail 10
|
||||
Write-Host ""
|
||||
} else {
|
||||
Write-ColorOutput "Log stdout nu exista inca" -Prefix "[INFO]"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# Verifică erori
|
||||
$stderrLog = Join-Path $LogDir "telegram_bot_stderr.log"
|
||||
if (Test-Path $stderrLog) {
|
||||
$errLines = (Get-Content $stderrLog).Count
|
||||
if ($errLines -gt 0) {
|
||||
Write-ColorOutput "Exista erori in stderr log ($errLines linii)" -Prefix "[AVERTIZARE]"
|
||||
Write-Host "Ultimele 5 erori:"
|
||||
Get-Content $stderrLog -Tail 5
|
||||
Write-Host ""
|
||||
}
|
||||
}
|
||||
|
||||
# Comenzi utile
|
||||
Write-Host "[COMENZI UTILE]" -ForegroundColor Yellow
|
||||
Write-Host " - Restart: .\restart_service.ps1"
|
||||
Write-Host " - View logs: .\view_logs.ps1"
|
||||
Write-Host " - Dezinstaleaza: .\uninstall_service.ps1"
|
||||
Write-Host " - Redeploy: .\deploy.ps1"
|
||||
Write-Host ""
|
||||
|
||||
# PowerShell Quick Commands
|
||||
Write-Host "[POWERSHELL COMMANDS]" -ForegroundColor Yellow
|
||||
Write-Host " - Restart-Service $ServiceName"
|
||||
Write-Host " - Stop-Service $ServiceName"
|
||||
Write-Host " - Start-Service $ServiceName"
|
||||
Write-Host " - Get-Content '$stdoutLog' -Wait -Tail 20"
|
||||
Write-Host ""
|
||||
|
||||
Read-Host "Apasa Enter pentru a inchide"
|
||||
Reference in New Issue
Block a user