Starting Node as a service with NSSM

Ok don't try and use forever as a service with NSSM, NSSM is already looking for failures and restarting the application so this combined with forever doing the same thing ends up with you having millions of node processes and none of them working.

Simply start node with nssm. NSSM acts live forever and restarts the app if it fails so your good there.

The codes:

nssm remove service_name
nssm install service_name "path\to\nodejs\node.exe"
nssm set service_name AppDirectory "path\to\node\app"
nssm set service_name AppParameters "node_script.js 
additional_parameters"
nssm set service_name AppStdout "path\to\log\out.log"
nssm set service_name AppStderr "path\to\log\can\be\same\as\stdout\out.log"
nssm set service_name AppEnvironmentExtra "PORT=3100"
nssm start service_name

Replace all instances of service_name with the name of new service.

AppDirectory should have no trailing \

AppStdout and Appstderr are paths to files.

This will start an parent nssm application. This will start and look after your node process.