Running Node as a Service using NSSM

Before going here, I’ll recommend to read my earlier article on creating a Node.js program at:

https://harjinderkamboj.wordpress.com/2012/09/06/node-js-on-windows-and-azure/

So, I assume we have a Node.js program at C:\NodeProject\NodeServer.js

NSSM – the Non-Sucking Service Manager is a tool which allows any service to run as a windows service without much hassles. NSSM can be dowloaded from http://nssm.cc/

Image

Download the appropriate version of nssm. Copy the file nssm.exe at any location, say, C:\NodeProject\nssm.exe

Now, open the command prompt and run nssm to see what options are available. Here is the result:

Image

nssm install NodeService
New window will pop up. Add with the following fields:

Application: C:\Program Files (x86)\nodejs\node.exe (appropriate path to the Node installation)
Options: C:\NodeProject\NodeServer.js (path to the Server file)

Image

By clicking install service will give the message that service is installed successfully

Now check the Services to see if the NodeService is installed
Image

Right click the service and start the service.

Now see the program running in the browser at http://localhost:1337/

Image

To remove the service, use the following command:
nssm install NodeService

Advertisements

4 thoughts on “Running Node as a Service using NSSM

  1. “To remove the service, use the following command:
    nssm install NodeService”

    .. did you mean:

    nssm remove NodeService

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s