Using forever as a service in Windows
UPDATE: This didn't work at all. When my server restarted it would end up spawning millions of node processes all trying to start up and killing my machine. Don't use this method. Have just set nssm to launch the node process directly.
So I was trying to use forever a service is Windows but I kept getting an error when trying to start the service.
The is because I was trying to use forever start myapp.js
. But this will not work as it starts your app as a daemon and then stops. So as far as the service manager is concern it did not start correctly.
However you can also run forever as a long running process by leaving out the start
part of the command.
I am using NSSM to create the services. I provide parameters like source directory and working directory and also where to output the logs. The full nssm command look something like this:
nssm install [Service Name] [path to forever]\forever.cmd --sourceDir [path to source directory] --workingDir [path to working directory] -o [path to log folder]\out.log -e [path to log folder]\err.log -l [path to log folder]\app.log -a app.js
The -a appends to the logs.
Here are the full list of forever commands.