marklagendijk / node-pm2-windows-startup

Utility to make PM2 automatically resurrect on Windows startup
MIT License
219 stars 24 forks source link

Start using a service instead of startup registry entry #2

Open marklagendijk opened 9 years ago

marklagendijk commented 9 years ago

Currently pm2 resurrect is called via a command which runs based on registry startup entry. The problem with this approach is that it only runs after a user has logged in. This a a problem for servers.

Probably the solution to this is to trigger the pm2 resurrect command via a Windows service. This could be implemented using node-windows.

marklagendijk commented 9 years ago

Winser also looks very interesting. pm2 also can be used programmatically, so the following should work:

index.js:

var pm2 = require('pm2');
pm2.resurrect();

package.json

{
  "scripts": {
    "postinstall": "winser -i -s -c",
    "preuninstall": "winser -r -x -s",
  }
}

With this installing should just be a matter of npm install pm2-windows-startup -g and uninstalling of npm uninstall pm2-windows-startup -g.