# 서버 자동 재시작 스크립트 $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 } }