Iam trying to start a next.js app with 2 clusters in pm2. So mapped the command yarn start
to pm2 start yarn -i 2 --name "frontend" -- start
App starts and then crashes within a second.
[PM2] Starting /usr/bin/yarn in cluster_mode (2 instances)
[PM2] Done.
┌─────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ frontend │ default │ N/A │ cluster │ 14901 │ 0s │ 0 │ online │ 0% │ 33.8mb │ user │ disabled │
│ 1 │ frontend │ default │ N/A │ cluster │ 14908 │ 0s │ 0 │ online │ 0% │ 28.8mb │ user │ disabled │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Output of .log file
0|frontend | /usr/share/yarn/bin/yarn:2
0|frontend | argv0=$(echo "$0" | sed -e 's,\\,/,g')
0|frontend | ^^^^
0|frontend |
0|frontend | SyntaxError: missing ) after argument list
0|frontend | at Module._compile (internal/modules/cjs/loader.js:895:18)
0|frontend | at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
0|frontend | at Module.load (internal/modules/cjs/loader.js:815:32)
0|frontend | at Function.Module._load (internal/modules/cjs/loader.js:727:14)
0|frontend | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:301:25
0|frontend | at wrapper (/usr/local/lib/node_modules/pm2/node_modules/async/internal/once.js:12:16)
0|frontend | at next (/usr/local/lib/node_modules/pm2/node_modules/async/waterfall.js:96:20)
0|frontend | at /usr/local/lib/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
0|frontend | at WriteStream.<anonymous> (/usr/local/lib/node_modules/pm2/lib/Utility.js:186:13)
0|frontend | at WriteStream.emit (events.js:210:5)
Note: Starting the app as an npm application works, but in fork mode.