Heroku | Integration | PM2 Documentation
https://pm2.io/doc/en/runtime/integration/heroku/
PM2 - Guide, References, Tutorials and Best Practices about PM2 and Node.js.
Why do we use pm2-runtime here?
Looks like it cannot find config in the project root.
pm2-runtime start
error: missing required argument `app.js|json_file'
pm2 runs fine.
@nikolay-borzov Why do we use
pm2-runtimehere? Looks like it cannot find config in the project root.pm2-runtime start error: missing required argument `app.js|json_file'
pm2runs fine.
Did you successfully deployed to heroku?
I could deployed successfully to Heroku with pm2-runtime start index.js. Note: pm2 start index.js works ok with heroku local, but it doesn't when deployed. You need the pm2-runtime start index.js to deploy. Strange...
I was able to deploy to Heroku by specifying config pm2-runtime start ecosystem.config.js. As I understood calling pm2 second time duplicates processes. pm2-runtime restarts existing ones.
I haven't found any description of pm2-runtime. Perhaps it's possible to add a help page for this
I have the same problem with pm2-runtime.
I've a simple server listening at port 4000, I've configured 4 instances.
Below is the error I encounter:
[2018-08-22T07:50:13.285Z] PM2 log: Launching in no daemon mode
[2018-08-22T07:50:13.349Z] PM2 log: Starting execution sequence in -fork mode- for app name:node-webpack-babel-starter id:0
[2018-08-22T07:50:13.357Z] PM2 log: App name:node-webpack-babel-starter id:0 online
[2018-08-22T07:50:13.361Z] PM2 log: Starting execution sequence in -fork mode- for app name:node-webpack-babel-starter id:1
[2018-08-22T07:50:13.367Z] PM2 log: App name:node-webpack-babel-starter id:1 online
[2018-08-22T07:50:13.369Z] PM2 log: Starting execution sequence in -fork mode- for app name:node-webpack-babel-starter id:2
[2018-08-22T07:50:13.380Z] PM2 log: App name:node-webpack-babel-starter id:2 online
[2018-08-22T07:50:13.391Z] PM2 log: Starting execution sequence in -fork mode- for app name:node-webpack-babel-starter id:3
[2018-08-22T07:50:13.411Z] PM2 log: App name:node-webpack-babel-starter id:3 online
Example app listening on port 4000!
Example app listening on port 4000!
[2018-08-22T07:50:13.730Z] PM2 log: App [node-webpack-babel-starter] with id [2] and pid [22967], exited with code [1] via signal [SIGINT]
[2018-08-22T07:50:13.733Z] PM2 error: Cancelling versioning data parsing
[2018-08-22T07:50:13.734Z] PM2 log: Starting execution sequence in -fork mode- for app name:node-webpack-babel-starter id:2
Error: listen EADDRINUSE :::4000
at Server.setupListenHandle [as _listen2] (net.js:1335:14)
at listenInCluster (net.js:1383:12)
at Server.listen (net.js:1470:7)
at Function.listen (/home/box/mien/webpack-node/node_modules/express/lib/application.js:618:24)
at Object.listen (/home/box/mien/webpack-node/dist/webpack:/src/main.js:9:5)
at webpack_require (/home/box/mien/webpack-node/dist/webpack:/webpack/bootstrap:22:1)
at module.exports (/home/box/mien/webpack-node/dist/webpack:/webpack/bootstrap:74:1)
at Object.
[2018-08-22T07:50:13.349Z] PM2 log: Starting execution sequence in -fork mode- for app name:node-webpack-babel-starter id:0
Did you specify the number of instances and cluster mode? Just a wild guess.
My config looks like this:
module.exports = {
apps: [
{
name: 'reverse-proxy',
script: 'index.js',
exec_mode: 'cluster',
instances: 'max',
merge_logs: true,
dependencies: ['pm2-intercom']
}
]
};
Also
Error: listen EADDRINUSE :::4000
Means there is no way you can start multiple servers using the same port when using fork mode. Again it's just my guess.
@nikolay-borzov , Your guess was pretty accurate. Thank you! Solved the problem.
Wouldn't it be best to also have a log configuration here to stdout for Heroku, so it's not filling up the filesystem and works with their logplex and and 12factor setup?
https://devcenter.heroku.com/articles/management-visibility#logging