| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- # BUFF 同步脚本循环执行脚本(Windows PowerShell 版本)
- Continue = " Stop\
- = Split-Path -Parent System.Management.Automation.InvocationInfo.MyCommand.Path
- if (-not ) { = Get-Location }
- Set-Location
- = if () { } else { \python\ }
- = if () { [int] } else { 600 }
- function Write-Log {
- param([string])
- = Get-Date -Format \yyyy-MM-dd HH:mm:ss\
- = " \
- Write-Host
- = Join-Path \logs\sync_loop_20260408.log\
- = Split-Path -Parent
- if (-not (Test-Path )) { New-Item -ItemType Directory -Path -Force | Out-Null }
- Add-Content -Path -Value -Encoding UTF8
- }
- function Invoke-SyncScript {
- param([string])
- = Join-Path
- if (-not (Test-Path )) {
- Write-Log \[警告] 脚本不存在: \
- return False
- }
- try {
- Write-Log \[开始] 执行 ...\
- &
- if ( -eq 0) {
- Write-Log \[成功] 执行完成\
- return True
- }
- Write-Log \[失败] 执行失败,退出码: \
- return False
- }
- catch {
- Write-Log \[错误] 执行 时发生异常: \
- return False
- }
- }
- Write-Log \==========================================\
- Write-Log \BUFF 同步脚本循环启动\
- Write-Log \Python: \
- Write-Log \休眠时间: 秒\
- Write-Log \==========================================\
- = 0
- while (True) {
- ++
- = Get-Date
- Write-Log \==========================================\
- Write-Log \开始第 轮同步\
- Write-Log \==========================================\
- = True
- = Invoke-SyncScript \sync_goods.py\
- if (-not ) { = False }
- = Invoke-SyncScript \sync_float_price.py\
- if (-not ) { = False }
- = Invoke-SyncScript \sync_liquidity.py\
- if (-not ) { = False }
- = Get-Date
- = ( - ).TotalSeconds
- if () {
- Write-Log \本轮全部成功,耗时: 0 秒\
- }
- else {
- Write-Log \本轮有脚本执行失败,耗时: 0 秒\
- }
- Write-Log \等待 秒后开始下一轮...\
- Start-Sleep -Seconds
- }
|