Making a node.js service using NSSM

18.7k views Asked by At

I want to create a nodejs service, so that the node server starts as my computer starts, and i do not have to keep the command prompt open all the time. I m tryng to achieve this by using NSSM.

Here is the command to create the service:

nssm.exe install jewel-server C:\Program Files\nodejs\node.exe D:\jewel\server.js

Run service:

net start jewel-server

But this doesnt work and give this error:

The jewel-server service is starting.
The jewel-server service could not be started.

A service specific error occured: 3.

I checked error code 3 means the path is not correct but the is path correct. Can you tell what i am doing wrong, or is there any other open source & more reliable alternative to NSSM

Version:

NSSM
version: 2.24
Windows-7 64bit
3

There are 3 answers

0
utkarsh tyagi On BEST ANSWER

The way parameters were passed was not correct, So used the NSSM GUI to set the parametes:

Open GUI: nssm.exe install jewel-server

Once the GUI is open give in the following values.

Path: C:\Program Files\nodejs\node.exe
Arguments: D:\jewel\server.js
Press Install service

Done! You can start the service now.

0
user7513128 On

It's because of the space in the "Program Files". All you have to do is put it in quotes like so:

nssm.exe install jewel-server "C:\Program Files\nodejs\node.exe" D:\jewel\server.js

1
John Huang On

According to http://nssm.cc/commands You may want to try the following commands.

nssm install jewel-server "C:\Program Files\nodejs\node.exe"
nssm set jewel-server AppDirectory "D:\jewel"
nssm set jewel-server AppParameters server.js
nssm start jewel-server

You may check the nssm by

nssm edit jewel-server 
nssm status jewel-server

Hope this will help.