Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.61k stars 2.62k forks source link

PM2 does not start on boot. #5084

Open foxt opened 3 years ago

foxt commented 3 years ago

What's going wrong?

PM2 does not start on boot.

How could we reproduce this issue?

Attempt to run pm2 startup on macOS catalina.

Supporting information

$ pm2 report

--- PM2 report ----------------------------------------------------------------
Date                 : Sun May 30 2021 20:56:08 GMT+0100 (British Summer Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.6
node version         : 16.2.0
node path            : not found
argv                 : /usr/local/Cellar/node/16.2.0/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : me
uid                  : 501
gid                  : 20
uptime               : 1min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.6
node version         : 16.2.0
node path            : not found
argv                 : /usr/local/Cellar/node/16.2.0/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : me
uid                  : 501
gid                  : 20
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : darwin
type                 : Darwin
cpus                 : Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
cpus nb              : 16
freemem              : 284938240
totalmem             : 25769803776
home                 : /Users/me
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name       │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1   │ skrobbl    │ default     │ 1.0.0   │ fork    │ 79933    │ 106s   │ 0    │ online    │ 0.1%     │ 41.2mb   │ me       │ disabled │
│ 0   │ vol        │ default     │ N/A     │ fork    │ 79931    │ 106s   │ 0    │ online    │ 0%       │ 1.0mb    │ me       │ disabled │
└─────┴────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/Users/me/.pm2/pm2.log last 20 lines:
PM2        | 2021-05-30T20:54:15: PM2 log: ===============================================================================
PM2        | 2021-05-30T20:54:15: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2021-05-30T20:54:15: PM2 log: Time                 : Sun May 30 2021 20:54:15 GMT+0100 (British Summer Time)
PM2        | 2021-05-30T20:54:15: PM2 log: PM2 version          : 4.5.6
PM2        | 2021-05-30T20:54:15: PM2 log: Node.js version      : 16.2.0
PM2        | 2021-05-30T20:54:15: PM2 log: Current arch         : x64
PM2        | 2021-05-30T20:54:15: PM2 log: PM2 home             : /Users/me/.pm2
PM2        | 2021-05-30T20:54:15: PM2 log: PM2 PID file         : /Users/me/.pm2/pm2.pid
PM2        | 2021-05-30T20:54:15: PM2 log: RPC socket file      : /Users/me/.pm2/rpc.sock
PM2        | 2021-05-30T20:54:15: PM2 log: BUS socket file      : /Users/me/.pm2/pub.sock
PM2        | 2021-05-30T20:54:15: PM2 log: Application log path : /Users/me/.pm2/logs
PM2        | 2021-05-30T20:54:15: PM2 log: Worker Interval      : 30000
PM2        | 2021-05-30T20:54:15: PM2 log: Process dump file    : /Users/me/.pm2/dump.pm2
PM2        | 2021-05-30T20:54:15: PM2 log: Concurrent actions   : 2
PM2        | 2021-05-30T20:54:15: PM2 log: SIGTERM timeout      : 1600
PM2        | 2021-05-30T20:54:15: PM2 log: ===============================================================================
PM2        | 2021-05-30T20:54:21: PM2 log: App [vol:0] starting in -fork mode-
PM2        | 2021-05-30T20:54:21: PM2 log: App [skrobbl:1] starting in -fork mode-
PM2        | 2021-05-30T20:54:21: PM2 log: App [vol:0] online
PM2        | 2021-05-30T20:54:21: PM2 log: App [skrobbl:1] online

Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues

 ~  pm2 startup                                                                                                                                                                                           225ms  Sun 30 May 20:54:21 2021
[PM2] Init System found: launchd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/local/Cellar/node/16.2.0/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup launchd -u me --hp /Users/me
 !  ~  sudo env PATH=$PATH:/usr/local/Cellar/node/16.2.0/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup launchd -u me --hp /Users/me                                                                270ms  Sun 30 May 20:54:24 2021
[PM2][ERROR] Init system not found
Platform launchd
Template
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
      <key>Label</key>
      <string>com.PM2</string>
      <key>UserName</key>
      <string>me</string>
    <key>KeepAlive</key>
    <true/>
      <key>ProgramArguments</key>
      <array>
          <string>/bin/sh</string>
          <string>-c</string>
          <string>/usr/local/lib/node_modules/pm2/bin/pm2 resurrect</string>
      </array>
      <key>RunAtLoad</key>
      <true/>
      <key>OnDemand</key>
      <false/>
      <key>LaunchOnlyOnce</key>
      <true/>
      <key>EnvironmentVariables</key>
    <dict>
      <key>PATH</key>
      <string>/Applications/Wireshark.app/Contents/MacOS:/usr/local/Cellar/node/16.2.0/bin</string>
      <key>PM2_HOME</key>
      <string>/Users/me/.pm2</string>
    </dict>
      <key>StandardErrorPath</key>
      <string>/tmp/com.PM2.err</string>
      <key>StandardOutPath</key>
      <string>/tmp/com.PM2.out</string>
  </dict>
</plist>

Target path
/Users/me/Library/LaunchAgents/pm2.me.plist
Command list
[ 'launchctl load -w /Users/me/Library/LaunchAgents/pm2.me.plist' ]
[PM2] Writing init configuration in /Users/me/Library/LaunchAgents/pm2.me.plist
[PM2] Making script booting at startup...
[PM2] [-] Executing: launchctl load -w /Users/me/Library/LaunchAgents/pm2.me.plist...
/bin/sh: launchctl: command not found
[ERROR] Exit code : 127
[PM2][ERROR] launchctl load -w /Users/me/Library/LaunchAgents/pm2.me.plist failed, see error above.
Akszyn commented 3 years ago

in the android version I have a similar problem when i would like node Red to start immediately after running termux

` $ pm2 startup [PM2][ERROR] Init system not found /data/data/com.termux/files/usr/lib/node_modules/pm2/lib/API/Startup.js:209 throw new Error('Init system not found'); ^

Error: Init system not found at API.CLI.startup (/data/data/com.termux/files/usr/lib/node_modules/pm2/lib/API/Startup.js:209:13) at Command. (/data/data/com.termux/files/usr/lib/node_modules/pm2/lib/binaries/CLI.js:707:9) at Command.listener (/data/data/com.termux/files/usr/lib/node_modules/pm2/node_modules/commander/index.js:315:8) at Command.emit (events.js:210:5) at Command.parseArgs (/data/data/com.termux/files/usr/lib/node_modules/pm2/node_modules/commander/index.js:651:12) at Command.parse (/data/data/com.termux/files/usr/lib/node_modules/pm2/node_modules/commander/index.js:474:21) at Timeout._onTimeout (/data/data/com.termux/files/usr/lib/node_modules/pm2/lib/binaries/CLI.js:206:15) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7) ` Manually execute the pm2 start node-red command runs this service without any problems same as 'pm2 start /data/data/com.termux/files/usr/lib/node_modules' starts nr