Using Windows? Use the Non-Sucking Service Manager to run your Services/Servers

If you’re on Windows, a lot of programs may only offer running on startup, which requires a user to login in order for the program to start - when the machine restarts due to an update or other factors, the program won’t start without someone actually interacting with the machine, be it remotely or in person. Others may not even offer this option, so you have to use the Windows Task Scheduler (shudders) or the ol’ throw a shortcut into the start menu Startup folder technique. Running as a service means the program runs when Windows is finished booting, regardless of whether or not a user is logged in. This is ideal for hosting just about everything.

Non-Sucking Service Manager is a wrapper for the Windows service host, because for some reason Microsoft thought it necessary to make it impossible to create a service out of regular executables. NSSM makes this super easy, I find it invaluable for anything from game servers to even things that do offer service-type installation, as it’s generally easier to manage.

  • First, download the latest release of NSSM from their site.

  • Extract it to a simple location, i.e. C:/nssm. We’re going to use this for the PATH environment variable so it can be run from a command prompt in any directory.

Here are the instructions for the PATH setup. I’m assuming most people here know how to do it, if not - expand and have at it.

Adding the PATH entry
  • In your start menu search bar (I know, I know), type “environment variable” and select Edit the system environment variables
    image

  • In the resultant window, click Environment Variables… at the bottom.
    image

  • In the bottom portion of this new Environment Variables window, select the Path entry, and press Edit.

  • Click New, and enter the path to where you extracted your NSSM - followed by win64 if you’re on a 64 bit machine, and win32 on a 32 bit machine. ex: C:\nssm\win64 Press OK on all remaining open windows.

Now that NSSM can be called from any directory in an adminstrator command prompt, let’s put it to work.

The simplest way to use NSSM is with the GUI, which will open once you use the command nssm install <servicename> (minus the brackets).
image
The only mandatory fields are the path and the service name. Startup directory will default to the location of the executable. The information in other tabs is fairly self explanatory, and there’s more info here.

You can also bypass the GUI, with nssm install <servicename> <application> [<options>]

Other useful commands include:

  • nssm start <servicename>
  • nssm stop <servicename>
  • nssm restart <servicename>
  • nssm status <servicename>
  • nssm remove <servicename>
  • nssm reset <servicename> <parameter>
  • nssm set <servicename> <parameter>

To see all services currently running that are managed by nssm in PowerShell:
Get-WmiObject win32_service | ?{$_.PathName -like '*nssm*'} | select Name, DisplayName, State, PathName

I personally use nssm for just about every game server I ever run, as well as anything I just need running at all times. Basically anything I want as a service, as you might imagine. It’s very versatile, it even allows for I/O redirection and rotation of output files. Further documentation is available on the nssm website.

2 Likes

What services/game servers are you running with this currently? All steam based stuff or others?

Yeah usually stuff available on SteamCMD, and previously some modded MC servers. Occasionally there’s an odd man out, like the ElDewrito servers.
For the Steam stuff, I have a SteamCMD update script run first, and then the actual servers launch after it exits.
Currently, I actually only have Mordhau servers active. My friends are pretty fickle, so it’s convenient to have something easy to throw a new game server up on.

I :100: endorse NSSM. We use it at work for a lot of legacy applications that need to run as a service.

1 Like