diff --git a/packaging/installer/netx.iss b/packaging/installer/netx.iss index 115c09e..4c113ff 100644 --- a/packaging/installer/netx.iss +++ b/packaging/installer/netx.iss @@ -5,7 +5,7 @@ #define MyAppName "NetX" #ifndef MyAppVersion - #define MyAppVersion "0.4.8" + #define MyAppVersion "0.4.9" #endif #define MyAppPublisher "NetX" #define MyAppURL "https://github.com/hansjone/netx" diff --git a/packaging/manifest.example.json b/packaging/manifest.example.json index 3c8d6aa..faaf94f 100644 --- a/packaging/manifest.example.json +++ b/packaging/manifest.example.json @@ -1,11 +1,11 @@ { "channel": "stable", - "latest": "0.4.8", + "latest": "0.4.9", "min_compatible": "0.3.0", - "notes_url": "https://github.com/hansjone/netx/releases/tag/v0.4.8", + "notes_url": "https://github.com/hansjone/netx/releases/tag/v0.4.9", "windows": { - "url": "https://github.com/hansjone/netx/releases/download/v0.4.8/NetX-0.4.8-win64.zip", - "setup_url": "https://github.com/hansjone/netx/releases/download/v0.4.8/NetX-Setup-0.4.8.exe", + "url": "https://github.com/hansjone/netx/releases/download/v0.4.9/NetX-0.4.9-win64.zip", + "setup_url": "https://github.com/hansjone/netx/releases/download/v0.4.9/NetX-Setup-0.4.9.exe", "sha256": "", "size": 0 } diff --git a/packaging/netx_tray.ps1 b/packaging/netx_tray.ps1 index 6b2aa97..0674db0 100644 --- a/packaging/netx_tray.ps1 +++ b/packaging/netx_tray.ps1 @@ -101,7 +101,8 @@ if ($autoVal -match '^(1|true|yes|on)$') { $CheckUpdateOnLaunch = $true } $uiUrl = "http://${hostBind}:${port}/" -$ver = Get-NetxVersion -ProgramRoot $prog +$script:ver = Get-NetxVersion -ProgramRoot $prog +$ver = $script:ver $dbMode = Get-DbMode -EnvMap $map $dbModeLabel = if ($dbMode -eq "bundled") { if (([cultureinfo]::CurrentUICulture.Name -match '^(zh|zh-)')) { "内置库" } else { "built-in DB" } @@ -160,16 +161,25 @@ function Invoke-NetxScript { } function Update-NetxTrayTip { + # Refresh version after in-place updates (tray process may outlive version.json). + try { + $nowVer = Get-NetxVersion -ProgramRoot $prog + if ($nowVer -and $nowVer -ne $script:ver) { + $script:ver = $nowVer + if ($null -ne $script:miHeader) { $script:miHeader.Text = "NetX $script:ver" } + } + } catch {} $running = Test-NetxApiHealthy -HostName $hostBind -Port $port -TimeoutSec 1 $state = if ($running) { (T "Running" "运行中") } else { (T "Stopped" "已停止") } - $tip = "NetX $ver · $state · $dbModeLabel`n$uiUrl" + $v = $script:ver + $tip = "NetX $v · $state · $dbModeLabel`n$uiUrl" if ($tip.Length -gt 63) { # NotifyIcon.Text max ~63 chars on older Windows. - $tip = "NetX $ver · $state · $dbModeLabel" + $tip = "NetX $v · $state · $dbModeLabel" } $notify.Text = $tip } @@ -297,7 +307,8 @@ $menu.Padding = New-Object System.Windows.Forms.Padding(4, 4, 4, 4) $menu.Renderer = New-Object NetxMenuRenderer # --- header (info only) --- -$miHeader = New-NetxMenuItem -Text "NetX $ver" -Header +$script:miHeader = New-NetxMenuItem -Text "NetX $script:ver" -Header +$miHeader = $script:miHeader [void]$menu.Items.Add($miHeader) $miSub = New-NetxMenuItem -Text "$dbModeLabel · ${hostBind}:$port" -Muted @@ -478,10 +489,11 @@ $miUpdate.add_Click({ -WorkingDirectory $prog -WindowStyle Normal -Verb RunAs -Wait -PassThru $newVer = Get-NetxVersion -ProgramRoot $prog if ($null -ne $ap.ExitCode -and $ap.ExitCode -eq 0) { + $script:ver = $newVer $ver = $newVer - $miHeader.Text = "NetX $ver" + if ($script:miHeader) { $script:miHeader.Text = "NetX $script:ver" } [System.Windows.Forms.MessageBox]::Show( - (T "Updated to $ver. Restart the tray if the menu still shows the old version." "已更新到 $ver。若菜单仍显示旧版本,请退出托盘后重新打开。"), + (T "Updated to $script:ver." "已更新到 $script:ver。"), (T "NetX update" "NetX 更新"), [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information diff --git a/packaging/start_netx_app.ps1 b/packaging/start_netx_app.ps1 index e56c792..a795e44 100644 --- a/packaging/start_netx_app.ps1 +++ b/packaging/start_netx_app.ps1 @@ -1,4 +1,4 @@ -param( +param( [string]$ProgramRoot = "", [string]$DataRoot = "", [switch]$SkipBrowser = $false, @@ -118,21 +118,25 @@ if (-not (Test-Path $startScript)) { throw "start_netx.ps1 not found at $startScript" } -$startExtra = @( - "-SkipInstall", "-Background", - "-BindHost", $hostBind, "-Port", "$port" -) -if ($InlineSchedulers) { $startExtra += "-InlineSchedulers" } - Write-Host "==> Starting NetX (API + workers; UI via API on :$port)" -$startProc = Start-NetxPowerShell -File $startScript -Arguments $startExtra ` - -WorkingDirectory $prog -WindowStyle Hidden -Wait -PassThru -if ($startProc.ExitCode -ne 0) { exit $startProc.ExitCode } +# Run in-process with -Background so this console exits after /health (nested +# Start-Process -Wait on a Hidden child often never returns under UAC update). +$startArgs = @{ + SkipInstall = $true + Background = $true + BindHost = $hostBind + Port = $port +} +if ($InlineSchedulers) { $startArgs["InlineSchedulers"] = $true } +& $startScript @startArgs +if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $url = "http://${hostBind}:${port}/" -if (-not (Wait-NetxApiHealthy -HostName $hostBind -Port $port -TimeoutSec 30)) { - Write-Host "[ERR] NetX process exited 0 but /health not ready: $url" -ForegroundColor Red - exit 1 +if (-not (Test-NetxApiHealthy -HostName $hostBind -Port $port -TimeoutSec 2)) { + if (-not (Wait-NetxApiHealthy -HostName $hostBind -Port $port -TimeoutSec 30)) { + Write-Host "[ERR] NetX started but /health not ready: $url" -ForegroundColor Red + exit 1 + } } Write-Host "==> Open: $url" -ForegroundColor Green if (-not $SkipBrowser) { diff --git a/packaging/update_netx.ps1 b/packaging/update_netx.ps1 index 943bcbf..616ebf6 100644 --- a/packaging/update_netx.ps1 +++ b/packaging/update_netx.ps1 @@ -130,9 +130,12 @@ try { Write-Host "==> Update files applied" -ForegroundColor Green if (-not $NoStart) { - & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "start_netx_app.ps1") ` + # Same process (no nested powershell) so the update console can exit cleanly. + & (Join-Path $PSScriptRoot "start_netx_app.ps1") ` -ProgramRoot $prog -DataRoot $data -SkipBrowser + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { exit $LASTEXITCODE } } + Write-Host "==> Update complete. You can close this window." -ForegroundColor Green } finally { if (Test-Path $work) { Remove-Item -Recurse -Force $work -ErrorAction SilentlyContinue diff --git a/pyproject.toml b/pyproject.toml index 2ea3429..97dc5b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netx-ops" -version = "0.4.8" +version = "0.4.9" description = "netx operations tool: alarm-centric workflows with REST API and stdio MCP" readme = "README.md" requires-python = ">=3.11"