feat(monitor): 策略监控 wrapper+schtask 注册脚本(恒0/ASCII/08:05+21:30 两班) [vps]

strategy_monitor_wrapper.ps1: 逐字适配数据域范本——恒 exit 0(红态由
alerts/health 承载, exit 3 会污染调度层 schtask 自检)、清三 proxy env、
Set-Location C:\sanguo_vnpy_v2、日志落 data\migration_logs\strategy_monitor_*.txt、
C:\Python310\python.exe -X utf8 --shift $Shift。注释纯 ASCII
(PS5.1 无 BOM 按 GBK 解析中文注释=崩溃铁律)。
register_strategy_monitor_schtasks.ps1: sanguo-strategy-monitor-morn 08:05 /
-eve 21:30 两行注册(--% 反斜杠工法、/ru SYSTEM /rl HIGHEST、VERIFY 尾节
输出下次运行时间); noon 按需手动跑不注册。注册动作归 infra(部署口令后执行)。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 13:38:00 +08:00
parent 188bcbb4ff
commit 7ac74da6a4
2 changed files with 32 additions and 0 deletions
@@ -0,0 +1,16 @@
# register_strategy_monitor_schtasks.ps1 - register the two strategy monitor shifts (v1)
# 08:05 morning engine-face check (after 07:50 qmt-relogin, 85min before open)
# + 21:30 evening product/order-chain check (IS daily 20:45, xt_eod 21:00 done).
# noon is manual/agent-on-demand only (--shift noon), NOT registered.
# Same --% trick as register_akshare_schtasks.ps1 (backslash-eating workaround).
$env:http_proxy = ''
$env:https_proxy = ''
$env:all_proxy = ''
schtasks --% /create /tn sanguo-strategy-monitor-morn /tr "powershell -ExecutionPolicy Bypass -File C:\sanguo_vnpy_v2\scripts\strategy_monitor\strategy_monitor_wrapper.ps1 -Shift morn" /sc daily /st 08:05 /ru SYSTEM /rl HIGHEST /f
schtasks --% /create /tn sanguo-strategy-monitor-eve /tr "powershell -ExecutionPolicy Bypass -File C:\sanguo_vnpy_v2\scripts\strategy_monitor\strategy_monitor_wrapper.ps1 -Shift eve" /sc daily /st 21:30 /ru SYSTEM /rl HIGHEST /f
Write-Output "=== VERIFY next run times (expect tomorrow 08:05 / tomorrow 21:30) ==="
foreach ($t in @('sanguo-strategy-monitor-morn','sanguo-strategy-monitor-eve')) {
schtasks /query /tn $t /fo LIST /v | Select-String -Pattern '下次运行时间|Next Run Time' | ForEach-Object { Write-Output (" {0,-30} {1}" -f $t, $_.Line.Trim()) }
}
@@ -0,0 +1,16 @@
# strategy_monitor_wrapper.ps1 - sanguo-strategy-monitor schtask wrapper (v1, two shifts daily)
# exit ALWAYS 0: red state is carried by alerts.db + health JSON (exit 3 would
# pollute the scheduler-layer schtask check of the monitor itself).
param([string]$Shift = "eve")
$env:http_proxy = ''
$env:https_proxy = ''
$env:all_proxy = ''
Set-Location C:\sanguo_vnpy_v2
$ts = Get-Date -Format 'yyyyMMdd_HHmmss'
$logDir = 'C:\sanguo_vnpy_v2\data\migration_logs'
if (-not (Test-Path $logDir)) { New-Item -ItemType Directory -Path $logDir -Force | Out-Null }
$log = Join-Path $logDir "strategy_monitor_$ts.txt"
C:\Python310\python.exe -X utf8 C:\sanguo_vnpy_v2\scripts\strategy_monitor\strategy_monitor.py --shift $Shift *>> $log
$rc = $LASTEXITCODE
Add-Content -Path $log -Value "strategy_monitor shift=$Shift rc=$rc"
exit 0