0

I start my app with the following command:

pm2 start npm --name “my-site" -i 0 -- run runGlobalProduction

But I'm finding that its intermittently crashing and not re-starting, even though when I ls the . processes, "my-site" shows as online. I have to reload my-site to get it to work.

Checking the logs, I can see this error but its not very informative:

npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 0|my-sit | ERR! code ELIFECYCLE 0|my-sit | npm ERR! errno 1 0|my-sit | npm ERR! my-website@3.2.4 runGlobalProduction: export PORT=8080 CONFIG_PATH=config/web/global-production.config.json&&npm run apiServer 0|lmy-sit | npm ERR! Exit status 1

Ben Gannaway
  • 1,053
  • 1
  • 14
  • 28

1 Answers1

0

You have to save your node app using

  pm2 start [app_name]
  pm2 save

Then do:

 pm2 startup [operation system]

This will create a dump.pm2 file that pm2 needs to run your app on reboot.

Quite similar to this post

Rastalamm
  • 1,712
  • 3
  • 23
  • 32
  • Thanks but I have saved already. The problem is not so much when the machine reboots, but when the app itself crashes. PM2 should restart any instance that crashes but its failing – Ben Gannaway Dec 21 '18 at 16:42