RouteMaster is often run just as a Windows desktop application. You can configure Windows to run RouteMaster as a startup application, but this still requires a user to log on to the computer.
Running RouteMaster as a service solves this problem, because services run as soon as the PC boots. Because service applications don’t appear as regular windows on the desktop, we’ll configure RouteMaster to allow remote control for configuration via it’s internal REST API, and use NSSM (the “Non-sucking Service Manager”) to run RouteMaster as a service.
Installing the service
Install RouteMaster as normal, Then download NSSM. Unzip the NSSM archive and – using the command prompt – run nssm.exe
> nssm.exe install RouteMaster
You’ll see NSSM’s graphical UI which allows you to set the path the the RouteMaster application, normally
The important settings are the command line arguments passed to RouteMaster.
-p 7777This tells RouteMaster to run the REST API on TCP port 7777. Normally, the port number is allocated dynamically, but we need a fixed port number to allow us to communicate with RouteMaster when it’s a service.
-f C:\rmdataThis is optional, but tells RouteMaster to use the specified folder for its configuration and log files.
You can also enter a friendly name and description in the Details tab. Other fields do not need changing.
Once this is done, click OK and the service should appear in the list of Windows services.
Configuring the RouteMaster service
Now the service is running, we need to connect to it for configuration. We can do this using the RouteMaster from the command line, with the -c option.
routemaster.exe -c http://localhost:7777
This runs the RouteMaster UI, but connects to the REST API provided by the service. You can modify all the settings as if you were running RouteMaster on the desktop. You can also use this option to manage a routemaster instance running on a different machine, by entering the correct URL.
So now we have the RouteMaster application running as a service at startup. The last thing to check is that RouteMaster is configured to start in the “Run” mode. Make sure this checkbox is enabled in the “Configure Router…” dialog.
Logs and Settings Files
When running RouteMaster as a Windows service, logs and settings files will be stored in this directory:
Another advantage of running as a service is that the Service Manager can automatically restart the service if it crashes. Use the Windows “Services” tool to edit the service recovery properties as required