51 lines
1.6 KiB
PowerShell
51 lines
1.6 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
Set-Location -Path $PSScriptRoot
|
|
New-Item -ItemType Directory -Force -Path 'ouptsw' | Out-Null
|
|
|
|
$pidFile = Join-Path $PSScriptRoot 'ouptsw/wechat_algorithm_live.pid'
|
|
$outLogFile = Join-Path $PSScriptRoot 'ouptsw/wechat_algorithm_live.log'
|
|
$errLogFile = Join-Path $PSScriptRoot 'ouptsw/wechat_algorithm_live.err.log'
|
|
|
|
if (Test-Path $pidFile) {
|
|
$oldPid = (Get-Content $pidFile -Raw).Trim()
|
|
if ($oldPid) {
|
|
$oldProcess = Get-Process -Id ([int]$oldPid) -ErrorAction SilentlyContinue
|
|
if ($oldProcess) {
|
|
Write-Host "WeChat algorithm live monitor is already running: pid=$oldPid"
|
|
Write-Host 'Open http://127.0.0.1:8765/'
|
|
exit 0
|
|
}
|
|
}
|
|
}
|
|
|
|
$python = Join-Path $PSScriptRoot 'venv/Scripts/python.exe'
|
|
if (-not (Test-Path $python)) {
|
|
$python = Join-Path $PSScriptRoot '.venv/Scripts/python.exe'
|
|
}
|
|
if (-not (Test-Path $python)) {
|
|
$python = 'python'
|
|
}
|
|
|
|
$args = @(
|
|
'wechat_algorithm_live.py',
|
|
'--fps', '30',
|
|
'--host', '127.0.0.1',
|
|
'--port', '8765',
|
|
'--click-on-badge',
|
|
'--llm-on-click',
|
|
'--llm-on-chat-change',
|
|
'--reply-on-chat-change',
|
|
'--send-reply',
|
|
'--typing-chunk-size', '2',
|
|
'--typing-delay', '0.08'
|
|
)
|
|
|
|
$process = Start-Process -FilePath $python -ArgumentList $args -WorkingDirectory $PSScriptRoot -RedirectStandardOutput $outLogFile -RedirectStandardError $errLogFile -PassThru -WindowStyle Hidden
|
|
Set-Content -Path $pidFile -Value $process.Id -NoNewline
|
|
|
|
Write-Host "WeChat algorithm live monitor started: pid=$($process.Id)"
|
|
Write-Host 'Open http://127.0.0.1:8765/'
|
|
Write-Host "Log: $outLogFile"
|
|
Write-Host "Error log: $errLogFile"
|