Error 1053 — sc.exe alone cannot run non-service-aware .exe. ntfy-bridge needs NSSM (Non-Sucking Service Manager) wrapper. - service.v: --install-service uses nssm.exe (auto-detect PATH or dir) - scripts/install.ps1: auto-downloads NSSM 2.24 before installing - Falls back to sc.exe for uninstall/status if nssm not found
This commit is contained in:
+38
-10
@@ -16,25 +16,50 @@ Write-Host ""
|
||||
$v = Get-Command v -ErrorAction SilentlyContinue
|
||||
if (-not $v) {
|
||||
Write-Host "V compiler not found. Downloading..."
|
||||
|
||||
# Download V weekly build
|
||||
|
||||
$vUrl = "https://github.com/vlang/v/releases/download/weekly.2024.32/v_windows.zip"
|
||||
$vZip = "$env:TEMP\v_windows.zip"
|
||||
$vDir = "$env:LOCALAPPDATA\v"
|
||||
|
||||
|
||||
Invoke-WebRequest -Uri $vUrl -OutFile $vZip
|
||||
Expand-Archive -Path $vZip -DestinationPath $vDir -Force
|
||||
Remove-Item $vZip
|
||||
|
||||
|
||||
$env:PATH = "$vDir\v;$env:PATH"
|
||||
Write-Host "V installed to $vDir"
|
||||
}
|
||||
|
||||
# Install NSSM (required for Windows service)
|
||||
$nssmPath = "$env:ProgramFiles\ntfy-bridge\nssm.exe"
|
||||
if (-not (Test-Path $nssmPath)) {
|
||||
Write-Host "Downloading NSSM (Non-Sucking Service Manager)..."
|
||||
$nssmUrl = "https://nssm.cc/release/nssm-2.24.zip"
|
||||
$nssmZip = "$env:TEMP\nssm.zip"
|
||||
$nssmDir = "$env:TEMP\nssm_extract"
|
||||
|
||||
Invoke-WebRequest -Uri $nssmUrl -OutFile $nssmZip
|
||||
Expand-Archive -Path $nssmZip -DestinationPath $nssmDir -Force
|
||||
|
||||
# Find nssm.exe in the extracted folder (it's in a win64 subfolder)
|
||||
$nssmExe = Get-ChildItem -Path $nssmDir -Recurse -Name "nssm.exe" | Select-Object -First 1
|
||||
if (-not $nssmExe) {
|
||||
Write-Error "Could not find nssm.exe in the downloaded archive."
|
||||
exit 1
|
||||
}
|
||||
$extractedNssm = Join-Path $nssmDir $nssmExe
|
||||
|
||||
New-Item -ItemType Directory -Force -Path "$env:ProgramFiles\ntfy-bridge" | Out-Null
|
||||
Copy-Item -Force $extractedNssm $nssmPath
|
||||
Remove-Item $nssmZip
|
||||
Remove-Item -Recurse -Force $nssmDir
|
||||
Write-Host "NSSM installed to $nssmPath"
|
||||
}
|
||||
|
||||
# Build
|
||||
Write-Host "Building ntfy-bridge..."
|
||||
v -prod -o ntfy-bridge.exe .
|
||||
|
||||
# Copy to a permanent location
|
||||
# Copy to install directory
|
||||
$installDir = "$env:ProgramFiles\ntfy-bridge"
|
||||
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
|
||||
Copy-Item -Force ntfy-bridge.exe $installDir\
|
||||
@@ -47,9 +72,9 @@ if (-not (Test-Path "$installDir\ntfy-bridge.yaml")) {
|
||||
Write-Host " ⚠️ Edit $installDir\ntfy-bridge.yaml to configure your sources!" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Install as Windows service
|
||||
# Install as Windows service (via NSSM)
|
||||
Write-Host "Installing as Windows service..."
|
||||
& "$installDir\ntfy-bridge.exe" --install-service --config "$installDir\ntfy-bridge.yaml" 2>&1 | Out-Null
|
||||
& "$installDir\ntfy-bridge.exe" --install-service --config "$installDir\ntfy-bridge.yaml" 2>&1 | Write-Host
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Done! ntfy-bridge is installed and running as a Windows service." -ForegroundColor Green
|
||||
@@ -60,6 +85,9 @@ Write-Host " Dashboard: http://localhost:9090/"
|
||||
Write-Host " Health: http://localhost:9090/health"
|
||||
Write-Host ""
|
||||
Write-Host " Service commands:"
|
||||
Write-Host " sc query ntfy-bridge"
|
||||
Write-Host " sc stop ntfy-bridge"
|
||||
Write-Host " sc start ntfy-bridge"
|
||||
Write-Host " nssm status ntfy-bridge"
|
||||
Write-Host " nssm stop ntfy-bridge"
|
||||
Write-Host " nssm start ntfy-bridge"
|
||||
Write-Host " nssm remove ntfy-bridge confirm (uninstall)"
|
||||
Write-Host ""
|
||||
Write-Host " Logs: C:\ProgramData\ntfy-bridge\service.log"
|
||||
|
||||
Reference in New Issue
Block a user