[2026-05-27] 포맷 후 복구 설치 스크립트 추가

This commit is contained in:
2026-05-27 16:53:52 +09:00
parent 04577c63f1
commit 29db1bfcab
135 changed files with 2909 additions and 251 deletions
+28 -10
View File
@@ -1,21 +1,39 @@
# 워치독 스크립트 — 봇 생존 감시 + 자동 재시작
# 작업 스케줄러에서 5분마다 실행 (평일 09:00~15:10)
$ErrorActionPreference = "Stop"
$OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$env:PYTHONUTF8 = "1"
$env:PYTHONIOENCODING = "utf-8"
$PROJECT = Split-Path -Parent $PSScriptRoot
$LOG = "$PROJECT\logs\watchdog.log"
$utf8 = New-Object System.Text.UTF8Encoding $false
$LOG = "$PROJECT\logs\watchdog.log"
. "$PROJECT\scripts\stockbot_env.ps1"
$PYTHON = Resolve-StockBotPython -Project $PROJECT
$utf8 = New-Object System.Text.UTF8Encoding $false
Set-Location $PROJECT
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
[System.IO.File]::AppendAllText($LOG, "[$timestamp] 워치독 실행`n", $utf8)
function Write-WatchdogLog {
param([string]$Message)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
[System.IO.File]::AppendAllText($LOG, "[$timestamp] $Message`n", $utf8)
}
python scripts/_watchdog.py 2>&1 |
$holidayResult = & $PYTHON scripts\_is_trading_day.py 2>&1
if ($LASTEXITCODE -ne 0) {
Write-WatchdogLog "market closed - skipped ($holidayResult)"
exit 0
}
$now = Get-Date
$start = Get-Date -Hour 9 -Minute 0 -Second 0
$end = Get-Date -Hour 15 -Minute 10 -Second 59
if ($now -lt $start -or $now -gt $end) {
Write-WatchdogLog "outside watchdog window - skipped"
exit 0
}
Write-WatchdogLog "watchdog started"
& $PYTHON scripts\_watchdog.py 2>&1 |
ForEach-Object { [System.IO.File]::AppendAllText($LOG, "$_`n", $utf8) }
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
[System.IO.File]::AppendAllText($LOG, "[$timestamp] 워치독 완료`n", $utf8)
Write-WatchdogLog "watchdog finished"