diff --git a/.gitea/workflows/agent-release.yml b/.gitea/workflows/agent-release.yml index 5ca0f45..e7e4526 100644 --- a/.gitea/workflows/agent-release.yml +++ b/.gitea/workflows/agent-release.yml @@ -86,22 +86,6 @@ jobs: $env:GOOS = "windows"; $env:GOARCH = "amd64" go build -ldflags="-s -w -X main.Version=$env:VERSION" -o ../installer/vantage-agent-windows-amd64.exe ./cmd - - name: Cache nssm - id: cache-nssm - uses: actions/cache@v4 - with: - path: installer/nssm.exe - key: nssm-2.24-win64 - - - name: Fetch nssm - if: steps.cache-nssm.outputs.cache-hit != 'true' - working-directory: installer - shell: pwsh - run: | - Invoke-WebRequest -Uri https://nssm.cc/release/nssm-2.24.zip -OutFile nssm.zip - Expand-Archive -Path nssm.zip -DestinationPath nssm-extract -Force - Copy-Item nssm-extract/nssm-2.24/win64/nssm.exe -Destination nssm.exe - - name: Install WiX shell: pwsh run: dotnet tool install --global wix --version 5.* diff --git a/.gitignore b/.gitignore index a0f9a58..d55b96d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ build .env docs .superpowers -installer/*.exe +installer/vantage-agent-windows-amd64.exe installer/*.msi installer/nssm.zip installer/checksums-msi.txt diff --git a/installer/nssm.exe b/installer/nssm.exe new file mode 100644 index 0000000..6ccfe3c Binary files /dev/null and b/installer/nssm.exe differ diff --git a/installer/setup.ps1 b/installer/setup.ps1 index d32cb6f..74c34a0 100644 --- a/installer/setup.ps1 +++ b/installer/setup.ps1 @@ -32,6 +32,10 @@ function Invoke-Native { function Invoke-NativeSoft { param([string]$File, [string[]]$Arguments) Write-Log ("RUN(soft): {0} {1}" -f $File, ($Arguments -join " ")) + # Native stderr merged via 2>&1 becomes terminating errors under + # ErrorActionPreference=Stop; force Continue in this scope so a benign nssm + # message (e.g. "service has not been started") never aborts setup. + $ErrorActionPreference = "Continue" $out = & $File @Arguments 2>&1 if ($out) { Write-Log ("OUT: {0}" -f ($out -join "`n")) } Write-Log ("EXIT: {0}" -f $LASTEXITCODE) @@ -121,8 +125,10 @@ tls: true Invoke-Native -File $nssm -Arguments @("set", "VantageAgent", "AppRotateOnline", "1") Invoke-Native -File $nssm -Arguments @("set", "VantageAgent", "AppRotateBytes", "1048576") - # restart (not just start) so an upgrade picks up the new binary - Invoke-NativeSoft -File $nssm -Arguments @("restart", "VantageAgent") + # Service is freshly (re)installed and stopped here (teardown removed the old + # one on upgrade), so start it. "restart" would try to stop a not-running + # service and emit a stderr error. + Invoke-NativeSoft -File $nssm -Arguments @("start", "VantageAgent") Write-Log "=== setup ok ===" exit 0