mirror of
https://github.com/hansjone/netx.git
synced 2026-10-14 18:30:47 +08:00
Fix Windows service mode: it could neither start nor stop.
- Start: WinSW's NetX.out.log/err.log in data\runtime are the same files as start_netx.ps1's netx.out.log (case-insensitive) and stay open, so NetX could not truncate its log and every start failed. WinSW logs now go to data\runtime\service. - Stop: nothing told the service_run.ps1 supervisor to exit, so it kept restarting NetX and WinSW waited forever. stop_netx_app.ps1 writes the service.stop flag (-KeepSupervisor for the supervisor's own restarts), service_run checks it every second, and runtime_ctl / service_lifecycle write it before stopping the service. - WinSW launched powershell.exe as stop hook never reached the script (stuck on inherited std handles); run it via cmd with NUL stdin and output to data\runtime\service\stopexec.log. stop_netx_app.ps1 keeps a timestamped trace there. Offline Windows Sandbox: service install -> healthy in 28s, stop in 20s. Existing service installs need "install service" re-run to pick this up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c8806c38bd
commit
a7cc1f502b
4 changed files with 53 additions and 9 deletions
|
|
@ -57,7 +57,16 @@ function Start-NetxChildren {
|
|||
|
||||
function Stop-NetxChildren {
|
||||
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $stopPs1 `
|
||||
-ProgramRoot $prog -DataRoot $data
|
||||
-ProgramRoot $prog -DataRoot $data -KeepSupervisor
|
||||
}
|
||||
|
||||
function Wait-NetxStopFlag([int]$Seconds) {
|
||||
# Sleep in 1s steps so a service stop (stop flag) is noticed quickly.
|
||||
for ($i = 0; $i -lt $Seconds; $i++) {
|
||||
if (Test-Path $stopFlag) { return $true }
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
return (Test-Path $stopFlag)
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -83,11 +92,11 @@ try {
|
|||
Start-NetxChildren
|
||||
$failStreak = 0
|
||||
# Give API time to come up before counting failures again.
|
||||
Start-Sleep -Seconds ([Math]::Max(15, $HealthIntervalSec))
|
||||
$null = Wait-NetxStopFlag ([Math]::Max(15, $HealthIntervalSec))
|
||||
continue
|
||||
}
|
||||
}
|
||||
Start-Sleep -Seconds $HealthIntervalSec
|
||||
$null = Wait-NetxStopFlag $HealthIntervalSec
|
||||
}
|
||||
} catch {
|
||||
Write-SvcLog "ERROR: $($_.Exception.Message)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue