Windows Services
This guide covers configuring License Monitor to run as a Windows service using NSSM (Non-Sucking Service Manager).
Prerequisites
Section titled “Prerequisites”- Windows 10/11 or Windows Server 2016+
- Administrator access
- License Monitor binary installed
- NSSM (Non-Sucking Service Manager)
Installing NSSM
Section titled “Installing NSSM”-
Download NSSM
Download from the official website: https://nssm.cc/download
Or use a package manager:
Terminal window choco install nssmTerminal window scoop install nssmTerminal window # Download and extract to C:\Program Files\nssmInvoke-WebRequest -Uri "https://nssm.cc/release/nssm-2.24.zip" -OutFile "$env:TEMP\nssm.zip"Expand-Archive -Path "$env:TEMP\nssm.zip" -DestinationPath "C:\Program Files"Rename-Item "C:\Program Files\nssm-2.24" "C:\Program Files\nssm" -
Add to PATH (if manually installed)
Terminal window [Environment]::SetEnvironmentVariable("Path",$env:Path + ";C:\Program Files\nssm\win64",[EnvironmentVariableTarget]::Machine)
Installing License Monitor
Section titled “Installing License Monitor”-
Create installation directory
Terminal window # Create directoriesNew-Item -ItemType Directory -Path "C:\Program Files\LicenseMonitor" -ForceNew-Item -ItemType Directory -Path "C:\Program Files\LicenseMonitor\logs" -ForceNew-Item -ItemType Directory -Path "C:\Program Files\LicenseMonitor\config" -Force -
Download the binary
Terminal window # Download latest releaseInvoke-WebRequest `-Uri "https://github.com/keithce/license_monitor/releases/latest/download/license_monitor-windows-x86_64.exe" `-OutFile "C:\Program Files\LicenseMonitor\license_monitor.exe" -
Create configuration file
Terminal window @"# License Monitor Configuration[command_mode]command = "lmutil lmstat -a"interval_seconds = 300[api]enabled = truebind_address = "127.0.0.1"bind_port = 8080allow_public_bind = falserate_limit_requests = 100rate_limit_window_seconds = 60[daemon]log_file = "C:\\Program Files\\LicenseMonitor\\logs\\license_monitor.log"log_level = "warn"[update]channel = "stable"auto_check = false"@ | Out-File -FilePath "C:\Program Files\LicenseMonitor\config\config.toml" -Encoding UTF8 -
Verify installation
Terminal window & "C:\Program Files\LicenseMonitor\license_monitor.exe" --version
Creating the Windows Service
Section titled “Creating the Windows Service”-
Install the service with NSSM
Terminal window # Open NSSM GUInssm install LicenseMonitor# Or install directly from command linenssm install LicenseMonitor "C:\Program Files\LicenseMonitor\license_monitor.exe" -
Configure service parameters
Using the GUI, configure:
Tab Setting Value Application Path C:\Program Files\LicenseMonitor\license_monitor.exeApplication Startup directory C:\Program Files\LicenseMonitorApplication Arguments --config "C:\Program Files\LicenseMonitor\config\config.toml" --mode command --daemonDetails Display name License Monitor Service Details Description Monitors license server usage and provides API access Details Startup type Automatic Log on Log on as Local System (or dedicated service account) I/O Output (stdout) C:\Program Files\LicenseMonitor\logs\stdout.logI/O Error (stderr) C:\Program Files\LicenseMonitor\logs\stderr.logExit actions Restart delay 10000 ms Exit actions Default action Restart Or configure via command line:
Terminal window nssm set LicenseMonitor Application "C:\Program Files\LicenseMonitor\license_monitor.exe"nssm set LicenseMonitor AppDirectory "C:\Program Files\LicenseMonitor"nssm set LicenseMonitor AppParameters '--config "C:\Program Files\LicenseMonitor\config\config.toml" --mode command --daemon'nssm set LicenseMonitor DisplayName "License Monitor Service"nssm set LicenseMonitor Description "Monitors license server usage and provides API access"nssm set LicenseMonitor Start SERVICE_AUTO_STARTnssm set LicenseMonitor AppStdout "C:\Program Files\LicenseMonitor\logs\stdout.log"nssm set LicenseMonitor AppStderr "C:\Program Files\LicenseMonitor\logs\stderr.log"nssm set LicenseMonitor AppStdoutCreationDisposition 4nssm set LicenseMonitor AppStderrCreationDisposition 4nssm set LicenseMonitor AppRotateFiles 1nssm set LicenseMonitor AppRotateSeconds 86400nssm set LicenseMonitor AppRotateBytes 10485760nssm set LicenseMonitor AppExit Default Restartnssm set LicenseMonitor AppRestartDelay 10000 -
Start the service
Terminal window nssm start LicenseMonitor
Service Management
Section titled “Service Management”Common Commands
Section titled “Common Commands”# Start servicenssm start LicenseMonitor# orStart-Service LicenseMonitor
# Stop servicenssm stop LicenseMonitor# orStop-Service LicenseMonitor
# Restart servicenssm restart LicenseMonitor# orRestart-Service LicenseMonitor
# Check statusnssm status LicenseMonitor# orGet-Service LicenseMonitor
# View service configurationnssm dump LicenseMonitorService Status Check
Section titled “Service Status Check”# Detailed statusGet-Service LicenseMonitor | Format-List *
# Check if running(Get-Service LicenseMonitor).StatusLog Management
Section titled “Log Management”Viewing Logs
Section titled “Viewing Logs”# View application logGet-Content "C:\Program Files\LicenseMonitor\logs\license_monitor.log" -Tail 50
# Follow log in real-timeGet-Content "C:\Program Files\LicenseMonitor\logs\license_monitor.log" -Wait
# View Windows Event LogGet-EventLog -LogName Application -Source nssm -Newest 20Log Rotation
Section titled “Log Rotation”NSSM can handle log rotation automatically:
# Enable rotationnssm set LicenseMonitor AppRotateFiles 1
# Rotate dailynssm set LicenseMonitor AppRotateSeconds 86400
# Rotate at 10MBnssm set LicenseMonitor AppRotateBytes 10485760
# Keep rotated files (append date)nssm set LicenseMonitor AppRotateOnline 1Multiple Instances
Section titled “Multiple Instances”To run multiple License Monitor instances:
-
Create instance directories
Terminal window New-Item -ItemType Directory -Path "C:\Program Files\LicenseMonitor\instances\flexlm" -ForceNew-Item -ItemType Directory -Path "C:\Program Files\LicenseMonitor\instances\rlm" -Force -
Create instance configurations
Terminal window # FlexLM configuration@"[command_mode]command = "lmutil lmstat -a -c 27000@flexlm-server"interval_seconds = 300[api]enabled = truebind_address = "127.0.0.1"bind_port = 8081[daemon]log_file = "C:\\Program Files\\LicenseMonitor\\instances\\flexlm\\logs\\license_monitor.log"log_level = "warn""@ | Out-File "C:\Program Files\LicenseMonitor\instances\flexlm\config.toml" -Encoding UTF8# RLM configuration@"[command_mode]command = "rlmstat -a -c 5053@rlm-server"interval_seconds = 300[api]enabled = truebind_address = "127.0.0.1"bind_port = 8082[daemon]log_file = "C:\\Program Files\\LicenseMonitor\\instances\\rlm\\logs\\license_monitor.log"log_level = "warn""@ | Out-File "C:\Program Files\LicenseMonitor\instances\rlm\config.toml" -Encoding UTF8 -
Install services
Terminal window # FlexLM servicenssm install LicenseMonitor-FlexLM "C:\Program Files\LicenseMonitor\license_monitor.exe"nssm set LicenseMonitor-FlexLM AppParameters '--config "C:\Program Files\LicenseMonitor\instances\flexlm\config.toml" --daemon'nssm set LicenseMonitor-FlexLM DisplayName "License Monitor - FlexLM"# RLM servicenssm install LicenseMonitor-RLM "C:\Program Files\LicenseMonitor\license_monitor.exe"nssm set LicenseMonitor-RLM AppParameters '--config "C:\Program Files\LicenseMonitor\instances\rlm\config.toml" --daemon'nssm set LicenseMonitor-RLM DisplayName "License Monitor - RLM"# Start servicesnssm start LicenseMonitor-FlexLMnssm start LicenseMonitor-RLM
Firewall Configuration
Section titled “Firewall Configuration”Allow Inbound Connections
Section titled “Allow Inbound Connections”# Allow License Monitor API portNew-NetFirewallRule ` -DisplayName "License Monitor API" ` -Direction Inbound ` -Protocol TCP ` -LocalPort 8080 ` -Action Allow ` -Profile Domain,Private
# For multiple instancesNew-NetFirewallRule -DisplayName "License Monitor FlexLM" -Direction Inbound -Protocol TCP -LocalPort 8081 -Action AllowNew-NetFirewallRule -DisplayName "License Monitor RLM" -Direction Inbound -Protocol TCP -LocalPort 8082 -Action AllowRecovery Options
Section titled “Recovery Options”Configure Automatic Recovery
Section titled “Configure Automatic Recovery”Using Services MMC or PowerShell:
# Set recovery options via sc.exesc.exe failure LicenseMonitor reset= 86400 actions= restart/10000/restart/10000/restart/10000This configures:
- First failure: Restart after 10 seconds
- Second failure: Restart after 10 seconds
- Subsequent failures: Restart after 10 seconds
- Reset failure count after 1 day
Running as a Specific User
Section titled “Running as a Specific User”Create Service Account
Section titled “Create Service Account”# Create local service account$Password = Read-Host -AsSecureString "Enter password"New-LocalUser -Name "LicenseMonitorSvc" -Password $Password -Description "License Monitor Service Account"
# Grant Log on as a service right (via Local Security Policy or Group Policy)Configure Service to Use Account
Section titled “Configure Service to Use Account”nssm set LicenseMonitor ObjectName ".\LicenseMonitorSvc" "password"Troubleshooting
Section titled “Troubleshooting”Service Won’t Start
Section titled “Service Won’t Start”# Check NSSM statusnssm status LicenseMonitor
# View Windows Event LogGet-EventLog -LogName Application -Source nssm -Newest 10
# Test configuration manually& "C:\Program Files\LicenseMonitor\license_monitor.exe" --config "C:\Program Files\LicenseMonitor\config\config.toml" --debugPermission Errors
Section titled “Permission Errors”# Check file permissionsGet-Acl "C:\Program Files\LicenseMonitor" | Format-List
# Grant permissions to service account$acl = Get-Acl "C:\Program Files\LicenseMonitor\logs"$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("LicenseMonitorSvc", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")$acl.SetAccessRule($rule)Set-Acl "C:\Program Files\LicenseMonitor\logs" $aclRemove Service
Section titled “Remove Service”# Stop and remove servicenssm stop LicenseMonitornssm remove LicenseMonitor confirmNext Steps
Section titled “Next Steps”- Reverse Proxy - Nginx/Apache configuration
- Production Setup - Production hardening
- Troubleshooting - Common issues