Instructor: One of the easiest ways to install a node application as a window service is to use an application called NSSM. NSSM stands for the Non-Sucking Service Manager, and you can download it from this URL.
After installing NSSM, if you open a command prompt with administration access and navigate to the directory, entering NSSM on its own will give you a list of commands. What we want to use is NSSM install.
We're also going to give it a name. I recommend you prefix all your services with a common set of initials, making them easier to find in the task manager. We'll call ours MBS. This will then display the NSSM GUI.
Within the NSSM GUI, the first thing we want to do is find the path to our node.exe. This is what we're going to use to start our node service.
The next thing we need is a startup directory. This is the directory that our app lives in. Finally, we need to give the arguments we would give to the command line. In our case, we would use start, as in node-start.
The service name is what we gave it when we launched this GUI, and that's fine. The details, we will keep the display name the same. The description should be something meaningful who would understand what the service does.
Startup type, will either be automatic, so when the service reboots the service restarts, which is what you would normally want.
Automatic delayed start, that will be if you want the service to not start initially and give a chance for something else to start. Manual and disabled are if you don't want this to be an automatic starting service. Log on.
This is a test box. We're going to use a local system account. In production, you should use a user account that has sufficient access to run the service.
Dependencies, this allows you to define other services that this service may rely on. For instance, you may want to specify MongoDB starts first before this service starts. Let's install the service. We get a prompt back from NSSM saying successfully installed.
Looking under our services within task manager, we see our new service mbtest, which is currently stopped. I open the services up, find the disservice, I can now start it. My service is now successfully started. If the server is restarted, this service will start automatically.
One thing you need to do is you should be remotely monitoring your window services to make sure that this is running successfully.