0

I was recently trying to run a nodejs app I created using pm2 and this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04 However, for some reason it throws this error and is unable to start:

root@ip-XXXXXXXXXX:/home/ubuntu# systemctl status pm2-ubuntu.service
● pm2-ubuntu.service - PM2 process manager
   Loaded: loaded (/etc/systemd/system/pm2-ubuntu.service; enabled; vendor preset: enabled)
   Active: failed (Result: protocol) since Wed 2019-01-16 17:15:25 UTC; 5s ago
     Docs: https://pm2.keymetrics.io/
  Process: 1686 ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect (code=exited, status=0/SUCCESS)

Jan 16 17:15:25 ip-XXXXXXXXXX pm2[1686]: [PM2] Restoring processes located in /home/ubuntu/.pm2/dump.pm2
Jan 16 17:15:25 ip-XXXXXXXXXX pm2[1686]: ┌──────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
Jan 16 17:15:25 ip-XXXXXXXXXX pm2[1686]: │ App name │ id │ version │ mode │ pid  │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
Jan 16 17:15:25 ip-XXXXXXXXXX pm2[1686]: ├──────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
Jan 16 17:15:25 ip-XXXXXXXXXX pm2[1686]: │ index    │ 0  │ 1.0.0   │ fork │ 1394 │ online │ 0       │ 113s   │ 0%  │ 41.1 MB   │ root │ disabled │
Jan 16 17:15:25 ip-XXXXXXXXXX pm2[1686]: └──────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘

I tried editing the pm2.pid file with nano, but it does not exist. Is there something wrong with my install? What do I do?

PM2 logfile:

2019-01-16T16:51:39: PM2 log: ===============================================================================
2019-01-16T16:51:39: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2019-01-16T16:51:39: PM2 log: Time                 : Wed Jan 16 2019 16:51:39 GMT+0000 (Coordinated Universal Time)
2019-01-16T16:51:39: PM2 log: PM2 version          : 3.2.8
2019-01-16T16:51:39: PM2 log: Node.js version      : 10.15.0
2019-01-16T16:51:39: PM2 log: Current arch         : x64
2019-01-16T16:51:39: PM2 log: PM2 home             : /home/ubuntu/.pm2
2019-01-16T16:51:39: PM2 log: PM2 PID file         : /home/ubuntu/.pm2/pm2.pid
2019-01-16T16:51:39: PM2 log: RPC socket file      : /home/ubuntu/.pm2/rpc.sock
2019-01-16T16:51:39: PM2 log: BUS socket file      : /home/ubuntu/.pm2/pub.sock
2019-01-16T16:51:39: PM2 log: Application log path : /home/ubuntu/.pm2/logs
2019-01-16T16:51:39: PM2 log: Process dump file    : /home/ubuntu/.pm2/dump.pm2
2019-01-16T16:51:39: PM2 log: Concurrent actions   : 2
2019-01-16T16:51:39: PM2 log: SIGTERM timeout      : 1600
2019-01-16T16:51:39: PM2 log: ===============================================================================
2019-01-16T16:51:39: PM2 log: App [index:0] starting in -fork mode-
2019-01-16T16:51:39: PM2 log: App [index:0] online
2019-01-16T16:56:59: PM2 log: pm2 has been killed by signal, dumping process list before exit...
2019-01-16T16:56:59: PM2 log: Deleting process 0
2019-01-16T16:56:59: PM2 log: Stopping app:index id:0
2019-01-16T16:56:59: PM2 log: App [index:0] exited with code [0] via signal [SIGHUP]
2019-01-16T16:56:59: PM2 log: pid=10369 msg=process killed
2019-01-16T16:56:59: PM2 log: Exited peacefully
2019-01-16T16:57:41: PM2 log: ===============================================================================

any and all help is appreciated

kasperd
  • 30,455
  • 17
  • 76
  • 124
Jake t
  • 127
  • 2
  • 8
  • 2
    PM2 is unnecessary here (and this tutorial goes on the list of bad Internet tutorials). You can just [start your Node app directly from a systemd unit](https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/). – Michael Hampton Jan 16 '19 at 18:38
  • 1
    Thanks for sparing me, I dreaded having to use PM2 – Jake t Jan 16 '19 at 18:59
  • @MichaelHampton While I do think that systemd mostly replaced existing process managers, I think pm2 is likely an exception, particularly for it's "cluster mode". – jordanm Jan 16 '19 at 21:08
  • @MichaelHampton It worked! However, I now get an error that says "cannot get /" after configuring a reverse proxy with the following code `location /iwl { proxy_pass http://localhost:6060; }` You can see this in action at http://jakesandbox.com/iwl – Jake t Jan 16 '19 at 21:27
  • so what was the solution? What is it even that worked now, pm2 or systemd? While @MichaelHampton gives a good hint, there are valid reasons to use pm2 and the question here remains unanswered... – N4ppeL Aug 13 '19 at 09:34

0 Answers0