File size: 970 Bytes
9d377df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9fa456d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# μ„œλ²„ μžλ™ μž¬μ‹œμž‘ 슀크립트
$ErrorActionPreference = "Continue"
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $scriptPath

function Start-Server {
    Write-Host "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] μ„œλ²„ μ‹œμž‘ 쀑..." -ForegroundColor Green
    
    $process = Start-Process -FilePath "python" -ArgumentList "run.py" -PassThru -NoNewWindow -Wait
    
    if ($process.ExitCode -ne 0) {
        Write-Host "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] μ„œλ²„κ°€ μ’…λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€. 5초 ν›„ μž¬μ‹œμž‘ν•©λ‹ˆλ‹€..." -ForegroundColor Yellow
        Start-Sleep -Seconds 5
        Start-Server
    }
}

# λ¬΄ν•œ λ£¨ν”„λ‘œ μ„œλ²„ μ‹€ν–‰
while ($true) {
    try {
        Start-Server
    }
    catch {
        Write-Host "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] 였λ₯˜ λ°œμƒ: $_" -ForegroundColor Red
        Write-Host "5초 ν›„ μž¬μ‹œμž‘ν•©λ‹ˆλ‹€..." -ForegroundColor Yellow
        Start-Sleep -Seconds 5
    }
}