refactor(scheduler): 排程迁移出web进程,迁入scheduler worker

This commit is contained in:
sophie committed 2026-07-30 19:52:41 +08:00
1 parent 970ee06537
commit 74745a9d10
21 files changed
+652 -223

No files matched your search

+18 -3
View File
@@ -63,6 +63,7 @@ function Stop-StaleHxopsPythonProcesses {
[regex]::Escape((Join-Path $BackendPath "run.py")),
[regex]::Escape((Join-Path $BackendPath "worker_kb.py")),
[regex]::Escape((Join-Path $BackendPath "workers\worker_shipping_notice.py")),
[regex]::Escape((Join-Path $BackendPath "workers\worker_scheduler.py")),
[regex]::Escape((Join-Path $RepoRoot "scripts\rpa\freight_rpa_worker.py"))
)
@@ -334,6 +335,20 @@ function Start-ShippingWorkerWindow {
-Command ".\venv\Scripts\python.exe .\workers\worker_shipping_notice.py"
}
function Start-ScheduleWorkerWindow {
param(
[string]$BackendPath,
[string]$Mode,
[string]$DbUrl
)
Start-WorkerWindow `
-Title "schedule-worker" `
-WorkingDirectory $BackendPath `
-EnvPrefix (Get-DatabaseUrlExport -Mode $Mode -DbUrl $DbUrl) `
-Command ".\venv\Scripts\python.exe .\workers\worker_scheduler.py"
}
function Start-FreightRpaWorkerWindow {
param(
[string]$RepoRoot,
@@ -386,7 +401,8 @@ Start-BackendWindow -BackendPath $backendDir -Mode $DbMode -DbUrl $DatabaseUrl
if (-not $SkipWorker.IsPresent) {
Start-KbWorkerWindow -BackendPath $backendDir -Mode $DbMode -DbUrl $DatabaseUrl
Start-ShippingWorkerWindow -BackendPath $backendDir -Mode $DbMode -DbUrl $DatabaseUrl
$windowCount += 2
Start-ScheduleWorkerWindow -BackendPath $backendDir -Mode $DbMode -DbUrl $DatabaseUrl
$windowCount += 3
if (-not $SkipRpaWorker.IsPresent) {
Start-FreightRpaWorkerWindow -RepoRoot $repoRoot -BackendPath $backendDir -EnvFiles $envFiles
$windowCount += 1
@@ -398,8 +414,7 @@ $windowCount += 1
Write-Host ""
Write-Host "Started in $windowCount new PowerShell windows." -ForegroundColor Green
if (-not $SkipWorker.IsPresent) {
Write-Host "Workers: kb-worker, shipping-worker$(if (-not $SkipRpaWorker.IsPresent) { ', freight-rpa-worker (mock)' })" -ForegroundColor Green
Write-Host "Schedule worker runs inside backend process (SCHEDULE_WORKER_ENABLED)." -ForegroundColor DarkGray
Write-Host "Workers: kb-worker, shipping-worker, schedule-worker$(if (-not $SkipRpaWorker.IsPresent) { ', freight-rpa-worker (mock)' })" -ForegroundColor Green
}
Write-Host "Frontend URL: http://127.0.0.1:8881" -ForegroundColor Green
Write-Host "Backend URL: http://127.0.0.1:5052" -ForegroundColor Green