### Install a service with a pre-launch script Source: https://github.com/aelassas/servy/wiki/Servy-CLI Configures a service that executes a pre-launch script for dynamic setup before the main application starts. ```powershell servy-cli install ` --name="MyLegacyService" ` --description="Runs legacy app with dynamic config" ` --path="C:\Apps\LegacyApp\LegacyApp.exe" ` --startupDir="C:\Apps\LegacyApp" ` --params="--mode=production" ` --preLaunchPath="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ` --preLaunchStartupDir="C:\Scripts" ` --preLaunchParams="-File C:\Scripts\GenerateConfig.ps1 -VaultUrl https://vault.example.com -SecretName AppSecrets" ` --preLaunchEnv="ENV=production;API_KEY=abcdef123" ` --preLaunchStdout="C:\Logs\prelaunch_stdout.log" ` --preLaunchStderr="C:\Logs\prelaunch_stderr.log" ` --preLaunchTimeout=60 ` --preLaunchRetryAttempts=2 ` --preLaunchIgnoreFailure ` --enableHealth ` --heartbeatInterval=30 ` --maxFailedChecks=3 ` --recoveryAction="RestartService" ` --maxRestartAttempts=5 ` --stdout="C:\Logs\service_stdout.log" ` --stderr="C:\Logs\service_stderr.log" ` --enableSizeRotation ` --rotationSize=10 ``` -------------------------------- ### Install a service with standard parameters Source: https://github.com/aelassas/servy/wiki/Servy-CLI Basic usage of the install command for configuring a service. ```powershell servy-cli install ` --name="My NodeJS Service" ` --description="My NodeJS Server" ` --path="C:\Program Files\nodejs\node.exe" ` --startupDir="C:\Apps\App" ` --params="C:\Apps\App\index.js" ` --startupType="Automatic" ` --priority="Normal" ` --stdout="C:\Apps\App\stdout.log" ` --stderr="C:\Apps\App\stderr.log" ` --enableSizeRotation ` --rotationSize=10 ` --enableHealth ` --heartbeatInterval=10 ` --maxFailedChecks=3 ` --recoveryAction="RestartService" ` --maxRestartAttempts=5 ` --envVars="ENV_VAR1=VAL1; ENV_VAR2=VAL2;" ` --deps="MongoDB; MySQL80" ``` -------------------------------- ### View Install Command Details Source: https://github.com/aelassas/servy/wiki/Servy-CLI Displays the full list of configuration parameters available for the install command. ```text PS> servy-cli install --help Servy.CLI + Copyright © 2026 Akram El Assas. All rights reserved. -n, --name Required. Unique service name to install. --displayName The human-readable name shown in the Windows Services console (services.msc). If left empty, the service name will be used instead. -d, --description Description of the service. -p, --path Required. Path to the executable process. Supports environment variable expansion, example: %JAVA_HOME%\bin\java.exe --startupDir Startup directory for the process. Supports environment variable expansion, example: %PROGRAMDATA%\MyApp --params Additional parameters for the process. Supports environment variable expansion, example: --params="--data %ProgramData%\MyApp --bin %MY_VAR%\bin". SECURITY WARNING: Use the SERVY_PROCESS_PARAMETERS environment variable instead to avoid exposing sensitive parameters in OS process listings. --startupType Service startup type. Options: Automatic, AutomaticDelayedStart, Manual, Disabled. --priority Process priority level. Options: Idle, BelowNormal, Normal, AboveNormal, High, RealTime. -a, --cpuAffinity Logical CPUs the process may run on (e.g., '0-3,8' or '0xFF00'). --startTimeout Timeout in seconds to wait for the process to start successfully before considering the startup as failed. Must be between 1 and 86400 seconds. Defaults to 10 seconds. --stopTimeout Timeout in seconds to wait for the process to exit. Must be between 1 and 86400 seconds. Defaults to 5 seconds. --enableConsoleUI Enable console user interface for the service. When enabled, stdout/stderr redirection is disabled. --stdout Path to stdout log file. --stderr Path to stderr log file. --enableRotation Deprecated. Enable size-based log rotation. This option is kept only for backward compatibility. Use --enableSizeRotation instead. --enableSizeRotation Enable size-based log rotation. --rotationSize Log rotation size in Megabytes (MB). Must be between 1 and 10240 MB. --enableDateRotation Enable date-based log rotation based on the date interval specified by --dateRotationType. When both size-based and date-based rotation are enabled, size rotation takes precedence. --dateRotationType Date rotation type. Options: Daily, Weekly, Monthly, None (None disables date-based rotation; use when only size rotation is desired). --maxRotations Maximum rotated log files to keep. Must be between 0 and 10000. Set to 0 or leave empty for unlimited. --useLocalTimeForRotation Use local server time for log rotation instead of UTC. Default is false. --debug Whether debug logs are enabled. When enabled, environment variables and process parameters are recorded in the Servy.Service.log file. Not recommended for production environments, as these logs may contain sensitive information. --enableHealth Enable health monitoring. ``` -------------------------------- ### Install a Windows Service Source: https://github.com/aelassas/servy/wiki/Servy-CLI Use the install command to register an executable as a Windows service. ```cmd servy-cli install --name="MyService" --path="C:\path\to\MyApp.exe" ``` -------------------------------- ### Integrate Servy CLI in Jenkins Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD Example build step for a Jenkins Windows agent to install and start a service. ```powershell # Install or update service servy-cli install --name="MyApp" --path="C:\MyApp\MyApp.exe" --startupType="Automatic" # Start the service servy-cli start --name="MyApp" ``` -------------------------------- ### Install Service with Environment Variables via CLI Source: https://github.com/aelassas/servy/wiki/Environment-Variables Example of using the --envVars flag to define production environment variables during service installation. ```powershell servy-cli install ` --name="MyNodeService" ` --description="My NodeJS Server" ` --path="%ProgramFiles%\nodejs\node.exe" ` --startupDir="C:\Apps\App" ` --params="C:\Apps\App\index.js" ` --startupType="Automatic" ` --envVars="NODE_ENV=production; APP_CONFIG=C:\Apps\App\config.json" ``` -------------------------------- ### Installation File Paths Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD Default installation locations for the CLI executable and PowerShell module. ```text %ProgramFiles%\Servy\servy-cli.exe ``` ```text %ProgramFiles%\Servy\Servy.psm1 ``` -------------------------------- ### Configure GitHub Actions for Servy Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD Example workflow for installing and managing a Windows service using a GitHub Actions runner. ```yaml name: Install MyApp with Servy on: workflow_dispatch: jobs: test-servy: runs-on: windows-latest steps: - name: Install Servy via WinGet run: | winget install --id aelassas.Servy -e --accept-package-agreements --accept-source-agreements --silent shell: powershell - name: Verify Servy CLI installed run: | & "C:\Program Files\Servy\servy-cli.exe" --version --quiet shell: powershell - name: Install MyApp as a Windows Service run: | & "C:\Program Files\Servy\servy-cli.exe" install ` --name="MyApp" ` --path="C:\MyApp\MyApp.exe" ` --startupType="Automatic" ` --startupDir="C:\MyApp" shell: powershell - name: Start MyApp service run: | & "C:\Program Files\Servy\servy-cli.exe" start --name="MyApp" shell: powershell - name: Verify service status run: | Get-Service -Name MyApp shell: powershell ``` -------------------------------- ### Install a Service with Splatting Source: https://github.com/aelassas/servy/wiki/Servy-PowerShell-Module Install a new service using a hashtable for parameter management. ```powershell # CORRECT: Switch flags are included by presence or set to $true in the splat hashtable $installParams = @{ Name = "WexflowServer" Description = "Wexflow Workflow Engine" Path = "C:\Program Files\dotnet\dotnet.exe" StartupDir = "C:\Program Files\Wexflow Server\Wexflow.Server" Params = "Wexflow.Server.dll" StartupType = "Automatic" EnableHealth = $true RecoveryAction = "RestartService" HeartbeatInterval = 30 MaxFailedChecks = 3 } Install-ServyService @installParams # INCORRECT: Do not do this with inline switches # Install-ServyService -Quiet $true -EnableHealth $true # CORRECT: Use inline switches without values, or use splatting # Inline: Install-ServyService -Quiet -EnableHealth # Splatting: # $params = @{ Quiet = $true; EnableHealth = $true } # Install-ServyService @params ``` -------------------------------- ### Install Service via CLI Source: https://github.com/aelassas/servy/wiki/FAQ Use the CLI to install a service with a specific CPU affinity range. ```cmd servy-cli install --name="MyService" --path="C:\Apps\Worker.exe" --cpuAffinity="0-3,8" ``` -------------------------------- ### Integrate Servy CLI in TeamCity Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD Example command line build step for a TeamCity agent to install and start a service. ```powershell servy-cli install --name="MyApp" --path="C:\TeamCity\Builds\MyApp.exe" --startupType="Automatic" servy-cli start --name="MyApp" ``` -------------------------------- ### Install-ServyService Source: https://github.com/aelassas/servy/wiki/Logging-&-Log-Rotation Configures and installs a new service with logging and rotation parameters. ```APIDOC ## Install-ServyService ### Description Installs a new service and configures its logging behavior, including log file paths and rotation strategies. ### Parameters - **Stdout** (string) - Path to the standard output log file. - **Stderr** (string) - Path to the standard error log file. - **EnableSizeRotation** (switch) - Enables rotation based on file size. - **RotationSize** (int) - Size threshold for rotation. - **EnableDateRotation** (switch) - Enables rotation based on date. - **DateRotationType** (string) - Frequency of date-based rotation (Daily, Weekly, Monthly, None). - **UseLocalTimeForRotation** (switch) - Uses local time for rotation triggers. - **MaxRotations** (int) - Maximum number of log files to keep (0 = unlimited). - **EnableDebugLogs** (switch) - Enables debug logging to %ProgramData%\Servy\logs\Servy.Service.log. ``` -------------------------------- ### Install-ServyService Source: https://github.com/aelassas/servy/wiki/Servy-PowerShell-Module Installs a new Windows service with advanced configuration. ```APIDOC ## Install-ServyService ### Description Wraps the Servy CLI install command to turn any executable into a managed Windows service with support for logging, health checks, and lifecycle management. ### Parameters - **-Name** (string) - Required - The name of the service. - **-Path** (string) - Required - The path to the executable. ### Example `Install-ServyService -Name "MyApp" -Path "C:\App\app.exe"` ``` -------------------------------- ### Automate Service Installation with PowerShell Source: https://github.com/aelassas/servy/wiki/FAQ Use the Servy PowerShell module to define installation parameters, including CPU affinity, and register the service. ```powershell Import-Module "C:\Program Files\Servy\Servy.psm1" -Force $installParams = @{ Name = "MyService" Path = "C:\Apps\Worker.exe" CpuAffinity = "0,2,4" # Binds process specifically to Cores 0, 2, and 4 } Install-ServyService @installParams ``` -------------------------------- ### Silent Installation Logging Source: https://github.com/aelassas/servy/wiki/Installation-Guide Enable installation logging by appending this switch to the installer command. ```text /LOG="servy-install.log" ``` -------------------------------- ### Silent Installation via PowerShell Source: https://github.com/aelassas/servy/wiki/Installation-Guide Use Start-Process to run the installer silently and refresh the system PATH environment variable. ```powershell # For .NET 10.0+ (x64) Start-Process -FilePath ".\servy--x64-installer.exe" -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /CLOSEAPPLICATIONS /NOCANCEL' -Verb RunAs -Wait # For .NET 10.0+ (ARM64) Start-Process -FilePath ".\servy--arm64-installer.exe" -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /CLOSEAPPLICATIONS /NOCANCEL' -Verb RunAs -Wait # For .NET Framework 4.8 Start-Process -FilePath ".\servy--net48-x64-installer.exe" -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /CLOSEAPPLICATIONS /NOCANCEL' -Verb RunAs -Wait # Refresh PATH in current session $env:Path = ((( [Environment]::GetEnvironmentVariable('Path', 'Machine'), [Environment]::GetEnvironmentVariable('Path', 'User') ) -join ';').Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Select-Object -Unique) -join ';' ``` -------------------------------- ### Install a Windows Service Source: https://github.com/aelassas/servy/wiki/Servy-PowerShell-Module Wraps the Servy CLI to install an executable as a managed Windows service with various configuration options. ```powershell Install-ServyService -Name "MyApp" -Path "C:\App\app.exe" ``` ```powershell Install-ServyService -Name "MyApp" -DisplayName "My App" -Path "C:\App\app.exe" ``` ```powershell Install-ServyService -Name "LogApp" -Path "C:\App\app.exe" -Stdout "C:\App\stdout.log" -EnableSizeRotation -RotationSize 10 ``` ```powershell Install-ServyService -Name "SecureApp" -Path "C:\App\app.exe" -EnvVars "API_KEY=12345;DB_PORT=5432" ``` -------------------------------- ### Install Bun Application as a Service Source: https://github.com/aelassas/servy/wiki/Examples-&-Recipes Configuration for running Bun backend services. ```powershell servy-cli install ` --name="MyBunService" ` --description="Bun backend service" ` --path="C:\tools\bun\bun.exe" ` --params="C:\apps\bun\server.ts" ` --startupDir="C:\apps\bun" ` --startupType="Automatic" ``` -------------------------------- ### Install Service with Dependencies via CLI Source: https://github.com/aelassas/servy/wiki/Service-Dependencies Use the --deps flag to specify semicolon-separated service names during installation. ```powershell servy-cli install ` --name="MyNodeService" ` --description="My NodeJS Server" ` --path="C:\Program Files\nodejs\node.exe" ` --startupDir="C:\Apps\App" ` --params="C:\Apps\App\index.js" ` --startupType="Automatic" ` --deps="MongoDB; MySQL80" ``` -------------------------------- ### Install Servy via Package Managers Source: https://github.com/aelassas/servy/wiki/Installation-Guide Commands to install Servy using WinGet, Chocolatey, or Scoop. ```powershell winget install servy ``` ```powershell choco install -y servy ``` ```powershell scoop bucket add extras scoop install servy ``` -------------------------------- ### Install WingetCreate Source: https://github.com/aelassas/servy/blob/main/setup/winget/README.md Installs the Microsoft WingetCreate tool required for manifest generation. ```powershell winget install Microsoft.WingetCreate ``` -------------------------------- ### Start-ServyService Source: https://github.com/aelassas/servy/wiki/Servy-PowerShell-Module Starts a Windows service. ```APIDOC ## Start-ServyService ### Description Triggers the service start signal, including any defined PreLaunch processes. ### Parameters - **-Name** (string) - Required - The name of the service. - **-Quiet** (switch) - Optional - Suppress output. ### Example `Start-ServyService -Name "MyApp"` ``` -------------------------------- ### Manual Download URLs Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD Direct download links for various Servy installer versions. ```text https://github.com/aelassas/servy/releases/download/v/servy--x64-installer.exe ``` ```text https://github.com/aelassas/servy/releases/download/v/servy--arm64-installer.exe ``` ```text https://github.com/aelassas/servy/releases/download/v/servy--net48-x64-installer.exe ``` -------------------------------- ### Start a Service Source: https://github.com/aelassas/servy/blob/main/README.md Commands to start a configured service using either the Servy CLI or the native Windows Service Control Manager. ```cmd servy-cli start --name="MyService" ``` ```cmd sc.exe start MyService ``` -------------------------------- ### Install Service with Dependencies via PowerShell Source: https://github.com/aelassas/servy/wiki/Service-Dependencies Pass a semicolon-separated string to the Deps parameter within the installation hashtable. ```powershell Import-Module "C:\Program Files\Servy\Servy.psm1" -Force $installParams = @{ Name = "MyNodeService" Description = "My NodeJS Server" Path = "C:\Program Files\nodejs\node.exe" StartupDir = "C:\Apps\App" Params = "C:\Apps\App\index.js" StartupType = "Automatic" Deps = "MongoDB; MySQL80" } Install-ServyService @installParams ``` -------------------------------- ### Install Ghost CMS as a Service Source: https://github.com/aelassas/servy/wiki/Examples-&-Recipes Sets up a Node.js-based Ghost CMS instance as a background service. ```powershell servy-cli install ` --name="GhostCMS" ` --path="C:\Program Files\nodejs\node.exe" ` --params="current\index.js" ` --startupDir="C:\var\www\ghost" ` --startupType="Automatic" ``` -------------------------------- ### Run a PocketBase Instance as a Service Source: https://github.com/aelassas/servy/wiki/Examples-&-Recipes Installs the PocketBase single-file backend as a Windows service. ```powershell servy-cli install ` --name="PocketBase" ` --description="PocketBase backend" ` --path="C:\apps\pocketbase\pocketbase.exe" ` --params="serve --http=0.0.0.0:8090" ` --startupDir="C:\apps\pocketbase" ` --startupType="Automatic" ``` -------------------------------- ### Install a service with a dedicated account Source: https://github.com/aelassas/servy/wiki/Examples-&-Recipes Use the PowerShell CLI to install a service under a specific domain account while securely handling the password via environment variables. ```powershell # Set the password in the current process environment first $env:SERVY_PASSWORD = "your_secret_password" servy-cli install ` --name="MySecureService" ` --path="C:\apps\secure\app.exe" ` --startupDir="C:\apps\secure" ` --user="DOMAIN\svc-myapp" ` --startupType="Automatic" # Clear sensitive variables from memory immediately after use Remove-Item Env:SERVY_PASSWORD ``` -------------------------------- ### Custom Component Silent Installation Source: https://github.com/aelassas/servy/wiki/Installation-Guide Specify components to install during a silent setup using the SetupType and Components flags. ```text /SetupType=custom /Components=install_cli ``` ```text /SetupType=custom /Components=install_main_app ``` ```text /SetupType=custom /Components=install_manager ``` ```text /SetupType=custom /Components=install_main_app,install_cli ``` ```text /SetupType=custom /Components=install_manager,install_cli ``` -------------------------------- ### Install a Node.js HTTP server as a Windows service Source: https://github.com/aelassas/servy/wiki/Examples-&-Recipes Demonstrates how to point the Servy CLI to the Node.js runtime executable to host a JavaScript server as a service. ```powershell servy-cli install ` --name="HelloServer" ` --path="C:\Program Files\nodejs\node.exe" ` --params="server.js" ` --startupDir="C:\apps\hello" ` --startupType="Automatic" ``` -------------------------------- ### Configure Pre-Launch via CLI Source: https://github.com/aelassas/servy/wiki/Pre-Launch-&-Post-Launch-Actions Use the servy-cli install command to register a service with pre-launch parameters. ```powershell servy-cli install ` --name="MyService" ` --description="Runs app with dynamic config" ` --path="C:\Apps\App\App.exe" ` --startupDir="C:\Apps\App" ` --params="--mode=production" ` --preLaunchPath="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ` --preLaunchStartupDir="C:\Scripts" ` --preLaunchParams="-File C:\Scripts\GenerateConfig.ps1 -VaultUrl https://vault.example.com" ` --preLaunchEnv="ENV=production;API_KEY=abcdef123" ` --preLaunchStdout="C:\Logs\prelaunch_stdout.log" ` --preLaunchStderr="C:\Logs\prelaunch_stderr.log" ` --preLaunchTimeout="60" ` --preLaunchRetryAttempts="2" ` --preLaunchIgnoreFailure ``` -------------------------------- ### Configure Azure DevOps Pipeline Task Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD PowerShell task commands for installing and starting a service within an Azure DevOps pipeline. ```powershell servy-cli install --name="MyApp" --path="$(Build.ArtifactStagingDirectory)\MyApp.exe" --startupType="Automatic" servy-cli start --name="MyApp" ``` -------------------------------- ### Configure Install Parameters with Equals Sign Source: https://github.com/aelassas/servy/wiki/Servy-CLI Use an equals sign when passing arguments starting with double dashes to prevent the CLI from misinterpreting them as its own options. ```bash --params="--mode=production --port=7008" ``` -------------------------------- ### Install a generic application as a Windows service Source: https://github.com/aelassas/servy/wiki/Examples-&-Recipes Use this pattern to register any executable as a background service with specified parameters and startup configuration. ```powershell servy-cli install ` --name="MyService" ` --path="C:\path\to\app.exe" ` --params="optional arguments" ` --startupDir="C:\path\to" ` --startupType="Automatic" ``` -------------------------------- ### Manage services via Servy CLI Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD Standard commands for installing, starting, stopping, and checking the status of services. These commands return exit codes suitable for pipeline automation. ```powershell # Install or update a service servy-cli install --name="MyApp" --path="C:\MyApp\MyApp.exe" --startupType="Automatic" # Start a service servy-cli start --name="MyApp" # Get a service status servy-cli status --name="MyApp" # Stop a service servy-cli stop --name="MyApp" # Uninstall a service servy-cli uninstall --name="MyApp" ``` -------------------------------- ### Silent Installation Commands Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD Standard silent installation flags for Servy installers. ```cmd .\servy--x64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /CLOSEAPPLICATIONS /NOCANCEL .\servy--arm64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /CLOSEAPPLICATIONS /NOCANCEL .\servy--net48-x64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /CLOSEAPPLICATIONS /NOCANCEL ``` -------------------------------- ### Configure Pre-Launch via PowerShell Module Source: https://github.com/aelassas/servy/wiki/Pre-Launch-&-Post-Launch-Actions Use the Install-ServyService cmdlet with a parameter hash table to define service settings including pre-launch hooks. ```powershell Import-Module "C:\Program Files\Servy\Servy.psm1" -Force $installParams = @{ Name = "MyService" Description = "Runs app with dynamic config" Path = "C:\Apps\App\App.exe" StartupDir = "C:\Apps\App" Params = "--mode=production" PreLaunchPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" PreLaunchStartupDir = "C:\Scripts" PreLaunchParams = "-File C:\Scripts\GenerateConfig.ps1 -VaultUrl https://vault.example.com" PreLaunchEnv = "ENV=production;API_KEY=abcdef123" PreLaunchStdout = "C:\Logs\prelaunch_stdout.log" PreLaunchStderr = "C:\Logs\prelaunch_stderr.log" PreLaunchTimeout = 60 PreLaunchRetryAttempts = 2 PreLaunchIgnoreFailure = $true } Install-ServyService @installParams ``` -------------------------------- ### Silent CLI-Only Installation Commands Source: https://github.com/aelassas/servy/wiki/Servy-Automation-&-CI-CD Silent installation flags configured to install only the CLI component. ```cmd .\servy--x64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /CLOSEAPPLICATIONS /NOCANCEL /SetupType=custom /Components=install_cli .\servy--arm64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOSES /SP- /CLOSEAPPLICATIONS /NOCANCEL /SetupType=custom /Components=install_cli .\servy--net48-x64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /CLOSEAPPLICATIONS /NOCANCEL /SetupType=custom /Components=install_cli ``` -------------------------------- ### Start a Windows Service Source: https://github.com/aelassas/servy/wiki/Servy-PowerShell-Module Triggers the start signal for a managed service. ```powershell Start-ServyService -Name "MyApp" ``` -------------------------------- ### Install Service with Logging via CLI Source: https://github.com/aelassas/servy/wiki/Logging-&-Log-Rotation Configures a new service with log file paths and size-based rotation parameters using the command line interface. ```powershell servy-cli install ` --name="My NodeJS Service" ` --description="My NodeJS Server" ` --path="C:\Program Files\nodejs\node.exe" ` --startupDir="C:\Apps\App" ` --params="C:\Apps\App\index.js" ` --startupType="Automatic" ` --priority="Normal" ` --stdout="C:\Apps\App\stdout.log" ` --stderr="C:\Apps\App\stderr.log" ` --enableSizeRotation ` --rotationSize="10" ` --maxRotations="5" ` --debug ``` -------------------------------- ### CLI Service Installation with Post-Launch Hook Source: https://github.com/aelassas/servy/wiki/Pre-Launch-&-Post-Launch-Actions Configures a service with a post-launch script using the servy-cli tool. ```powershell servy-cli install ` --name="MyService" ` --description="Runs app with dynamic config" ` --path="C:\Apps\App\App.exe" ` --startupDir="C:\Apps\App" ` --params="--mode=production" ` --postLaunchPath="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ` --postLaunchStartupDir="C:\Scripts" ` --postLaunchParams="-File C:\Scripts\Notify.ps1 -VaultUrl https://vault.example.com" ``` -------------------------------- ### Servy-Dump.ps1 Usage Examples Source: https://github.com/aelassas/servy/wiki/Backup-Restore-&-VM-Cloning Demonstrates basic backup execution, forced overwrites, and service uninstallation during the dump process. ```powershell # Basic usage (fails with exit code 3 if destination archive already exists) .\Servy-Dump.ps1 -DestinationArchivePath "C:\Backups\Servy_Dump.zip" # Force overwrite of existing dump archive .\Servy-Dump.ps1 -DestinationArchivePath "C:\Backups\Servy_Dump.zip" -Overwrite # Force overwrite of existing dump archive, uninstall each successfully exported service from the Windows SCM, and remove it from the Servy database .\Servy-Dump.ps1 -DestinationArchivePath "C:\Backups\Servy_Dump.zip" -Overwrite -Uninstall ``` -------------------------------- ### Check installed registry entries Source: https://github.com/aelassas/servy/blob/main/setup/choco/README.md Query Windows registry locations to confirm the installation details of Servy. ```powershell Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*, HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.DisplayName -like "Servy*" } | Select-Object DisplayName, DisplayVersion, UninstallString | Format-Table -AutoSize ``` -------------------------------- ### PowerShell Module Service Installation Source: https://github.com/aelassas/servy/wiki/Pre-Stop-&-Post-Stop-Actions Installs a service using the Servy PowerShell module with defined post-stop parameters. ```powershell Import-Module "C:\Program Files\Servy\Servy.psm1" -Force $installParams = @{ Name = "MyService" Description = "Runs app with dynamic config" Path = "C:\Apps\App\App.exe" StartupDir = "C:\Apps\App" Params = "--mode=production" PostStopPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" PostStopStartupDir = "C:\Scripts" PostStopParams = "-File C:\Scripts\Notify.ps1 -VaultUrl https://vault.example.com -SecretName AppSecrets" } Install-ServyService @installParams ``` -------------------------------- ### Install OCaml Script or App as a Service Source: https://github.com/aelassas/servy/wiki/Examples-&-Recipes Demonstrates running OCaml scripts via the interpreter or native compiled executables. ```powershell servy-cli install ` --name="MyOCamlService" ` --description="OCaml background worker" ` --path="C:\OCaml\bin\ocaml.exe" ` --params="C:\apps\ocaml\worker.ml" ` --startupDir="C:\apps\ocaml" ` --startupType="Automatic" ``` ```powershell servy-cli install ` --name="MyOCamlService" ` --description="OCaml compiled worker" ` --path="C:\apps\ocaml\worker.exe" ` --startupDir="C:\apps\ocaml" ` --startupType="Automatic" ``` -------------------------------- ### Silent Installation via Command Prompt Source: https://github.com/aelassas/servy/wiki/Installation-Guide Execute the installer silently from an administrator command prompt for different .NET versions. ```powershell # For .NET 10.0+ (x64) .\servy--x64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /CLOSEAPPLICATIONS /NOCANCEL # For .NET 10.0+ (ARM64) .\servy--arm64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /CLOSEAPPLICATIONS /NOCANCEL # For .NET Framework 4.8 .\servy--net48-x64-installer.exe /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /CLOSEAPPLICATIONS /NOCANCEL ``` -------------------------------- ### CLI Service Installation with Pre-Stop Source: https://github.com/aelassas/servy/wiki/Pre-Stop-&-Post-Stop-Actions Configures a service with a pre-stop hook using the Servy CLI. ```powershell servy-cli install ` --name="MyService" ` --description="Runs app with dynamic config" ` --path="C:\Apps\App\App.exe" ` --startupDir="C:\Apps\App" ` --params="--mode=production" ` --preStopPath="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ` --preStopStartupDir="C:\Scripts" ` --preStopParams="-File C:\Scripts\PreStop.ps1 -VaultUrl https://vault.example.com -SecretName AppSecrets" ` --preStopTimeout="60" ` --preStopLogAsError ``` -------------------------------- ### Install Servy Service with Health Monitoring Source: https://github.com/aelassas/servy/wiki/Health-Monitoring-&-Recovery Configures a service with health monitoring, heartbeat intervals, and recovery actions using PowerShell. ```powershell Import-Module "C:\Program Files\Servy\Servy.psm1" -Force $installParams = @{ Name = "MyNodeService" Description = "My NodeJS Server" Path = "C:\Program Files\nodejs\node.exe" StartupDir = "C:\Apps\App" Params = "C:\Apps\App\index.js" StartupType = "Automatic" EnableHealth = $true HeartbeatInterval = 10 MaxFailedChecks = 3 RecoveryAction = "RestartService" RecoveryOnCleanExit = $true MaxRestartAttempts = 3 HeartbeatUrl = "https://hc-ping.com/your-uuid-here" HeartbeatUrlTimeoutSeconds = 5 EnableHeartbeatUrlFlags = $true FailureProgramPath = "C:\Apps\FailureHandler.exe" FailureProgramStartupDir = "C:\Apps" FailureProgramParams = "-log C:\Logs\failure.log" } Install-ServyService @installParams ``` -------------------------------- ### Install Service with Logging via PowerShell Module Source: https://github.com/aelassas/servy/wiki/Logging-&-Log-Rotation Uses the Servy PowerShell module to install a service with defined logging and rotation settings via a parameter hash table. ```powershell Import-Module "C:\Program Files\Servy\Servy.psm1" -Force $installParams = @{ Quiet = $true Name = "My NodeJS Service" Description = "My NodeJS Server" Path = "C:\Program Files\nodejs\node.exe" StartupDir = "C:\Apps\App" Params = "C:\Apps\App\index.js" StartupType = "Automatic" Priority = "Normal" Stdout = "C:\Apps\App\stdout.log" Stderr = "C:\Apps\App\stderr.log" EnableSizeRotation = $true RotationSize = 10 MaxRotations = 5 EnableDebugLogs = $true } Install-ServyService @installParams ``` -------------------------------- ### Install a service using secure environment variables Source: https://github.com/aelassas/servy/wiki/Servy-CLI Recommended approach for production environments to avoid exposing sensitive credentials in process lists or shell history. ```powershell # 1. Set sensitive values in the current process environment $env:SERVY_PASSWORD = "your_secret_password" $env:SERVY_PROCESS_PARAMETERS = "C:\Apps\App\index.js" $env:SERVY_ENVIRONMENT_VARIABLES = "ENV_VAR1=VAL1; ENV_VAR2=VAL2;" # 2. Run the install command without sensitive CLI flags servy-cli install ` --name="My NodeJS Service" ` --description="My NodeJS Server" ` --path="C:\Program Files\nodejs\node.exe" ` --startupDir="C:\Apps\App" ` --startupType="Automatic" ` --priority="Normal" ` --stdout="C:\Apps\App\stdout.log" ` --stderr="C:\Apps\App\stderr.log" ` --enableSizeRotation ` --rotationSize=10 ` --enableHealth ` --heartbeatInterval=10 ` --maxFailedChecks=3 ` --recoveryAction="RestartService" ` --maxRestartAttempts=5 ` --deps="MongoDB; MySQL80" ` --user=".\serviceuser" # 3. Clear sensitive variables from memory immediately after use Remove-Item Env:SERVY_PASSWORD Remove-Item Env:SERVY_PROCESS_PARAMETERS Remove-Item Env:SERVY_ENVIRONMENT_VARIABLES ``` -------------------------------- ### Install WSL Bash Script as a Service Source: https://github.com/aelassas/servy/wiki/Examples-&-Recipes Configures a WSL bash script to run as a Windows service. Ensure the service is installed with the --user flag matching the distro owner to avoid WSL_E_DISTRO_NOT_FOUND errors. ```powershell servy-cli install ` --name="MyWSLScript" ` --description="WSL Bash script service" ` --path="C:\Windows\System32\wsl.exe" ` --params="bash /home/user/scripts/run.sh" ` --startupDir="C:\Windows\System32" ` --startupType="Automatic" ``` ```powershell servy-cli install ` --name="MyUbuntuWSLService" ` --description="WSL Ubuntu service job" ` --path="C:\Windows\System32\wsl.exe" ` --params="-d Ubuntu bash /home/user/app/start.sh" ` --startupDir="C:\Windows\System32" ` --startupType="Automatic" ``` -------------------------------- ### Verify published package Source: https://github.com/aelassas/servy/blob/main/setup/choco/README.md Search for and install the package from the remote repository. ```powershell choco search servy choco install servy -y ``` -------------------------------- ### Get-ServyHelp Source: https://github.com/aelassas/servy/wiki/Servy-PowerShell-Module Displays the Servy CLI help manual. Provides global usage instructions or detailed parameter explanations for a specific command if requested. ```APIDOC ## Get-ServyHelp ### Description Displays the Servy CLI help manual. Provides global usage instructions or detailed parameter explanations for a specific command if requested. ### Parameters - **-Command** (string) - Optional - Specific command to get help for. - **-Quiet** (switch) - Optional - Suppress output. ```