Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a node.js service using NSSM

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
like image 669
utkarsh tyagi Avatar asked Jan 07 '17 02:01

utkarsh tyagi


People also ask

How do I run node JS as a service?

var Service = require('node-windows'). Service; // Create a new service object var svc = new Service({ name:'Hello World', description: 'The nodejs.org example web server. ', script: 'C:\\path\\to\\my\\node\\script. js' }); // Listen for the "install" event, which indicates the // process is available as a service.


1 Answers

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.

like image 142
utkarsh tyagi Avatar answered Oct 13 '22 20:10

utkarsh tyagi