First
Some checks failed
Build All Docker Images / changes (push) Has been cancelled
Build and Push App Docker Image / build (push) Has been cancelled
Build and Push Node Docker Image / build (push) Has been cancelled
Test and Lint / test-app (push) Has been cancelled
Test and Lint / test-node (push) Has been cancelled
Test and Lint / lint-dockerfiles (push) Has been cancelled
Test and Lint / security-scan (push) Has been cancelled
Build All Docker Images / build-app (push) Has been cancelled
Build All Docker Images / build-node (push) Has been cancelled
Build All Docker Images / summary (push) Has been cancelled
Some checks failed
Build All Docker Images / changes (push) Has been cancelled
Build and Push App Docker Image / build (push) Has been cancelled
Build and Push Node Docker Image / build (push) Has been cancelled
Test and Lint / test-app (push) Has been cancelled
Test and Lint / test-node (push) Has been cancelled
Test and Lint / lint-dockerfiles (push) Has been cancelled
Test and Lint / security-scan (push) Has been cancelled
Build All Docker Images / build-app (push) Has been cancelled
Build All Docker Images / build-node (push) Has been cancelled
Build All Docker Images / summary (push) Has been cancelled
This commit is contained in:
commit
4169337dd0
68 changed files with 8726 additions and 0 deletions
54
node/install-windows-service.ps1
Normal file
54
node/install-windows-service.ps1
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# Windows Service Installation Script
|
||||
# Run as Administrator
|
||||
|
||||
$serviceName = "HomeServerAgent"
|
||||
$serviceDisplayName = "Home Server Agent"
|
||||
$serviceDescription = "Lightweight agent for managing game servers"
|
||||
$servicePath = "C:\Program Files\HomeServerAgent"
|
||||
$dockerComposePath = "$servicePath\docker-compose.yml"
|
||||
|
||||
# Check if running as administrator
|
||||
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
||||
Write-Warning "Please run this script as Administrator"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create service directory
|
||||
if (!(Test-Path $servicePath)) {
|
||||
New-Item -ItemType Directory -Path $servicePath -Force
|
||||
}
|
||||
|
||||
# Copy files to service directory
|
||||
Copy-Item -Path ".\*" -Destination $servicePath -Recurse -Force
|
||||
|
||||
# Install NSSM (Non-Sucking Service Manager) if not present
|
||||
$nssmPath = "$servicePath\nssm.exe"
|
||||
if (!(Test-Path $nssmPath)) {
|
||||
Write-Host "Downloading NSSM..."
|
||||
Invoke-WebRequest -Uri "https://nssm.cc/release/nssm-2.24.zip" -OutFile "$servicePath\nssm.zip"
|
||||
Expand-Archive -Path "$servicePath\nssm.zip" -DestinationPath $servicePath
|
||||
Copy-Item -Path "$servicePath\nssm-2.24\win64\nssm.exe" -Destination $nssmPath
|
||||
Remove-Item -Path "$servicePath\nssm.zip" -Force
|
||||
Remove-Item -Path "$servicePath\nssm-2.24" -Recurse -Force
|
||||
}
|
||||
|
||||
# Create service
|
||||
& $nssmPath install $serviceName "docker-compose"
|
||||
& $nssmPath set $serviceName AppDirectory $servicePath
|
||||
& $nssmPath set $serviceName AppParameters "up -d"
|
||||
& $nssmPath set $serviceName DisplayName $serviceDisplayName
|
||||
& $nssmPath set $serviceName Description $serviceDescription
|
||||
& $nssmPath set $serviceName Start SERVICE_AUTO_START
|
||||
& $nssmPath set $serviceName AppStopMethodConsole 30000
|
||||
& $nssmPath set $serviceName AppStopMethodWindow 30000
|
||||
& $nssmPath set $serviceName AppStopMethodThreads 30000
|
||||
& $nssmPath set $serviceName AppKillProcessTree 1
|
||||
|
||||
# Set service to restart on failure
|
||||
& $nssmPath set $serviceName AppRestartDelay 10000
|
||||
& $nssmPath set $serviceName AppNoConsole 1
|
||||
|
||||
Write-Host "Service installed successfully!"
|
||||
Write-Host "To start the service: Start-Service $serviceName"
|
||||
Write-Host "To stop the service: Stop-Service $serviceName"
|
||||
Write-Host "To remove the service: & '$nssmPath' remove $serviceName confirm"
|
||||
Loading…
Add table
Add a link
Reference in a new issue