I tried to install PM2 on my app, and it works perfectly fine on localhost. However the problem occurs, when I am moving app into the docker container and try to run on the Linux machine.
I am running command npm run production, which executes following code:
pm2 start ecosystem.config.js --env production --no-autorestart
Thereafter, on the command line I see how PM2 boots and start my app on all available cores.
app | [PM2] PM2 Successfully daemonized
app | [PM2][WARN] Applications App not running, starting...
app | [PM2] App [App] launched (2 instances)
app | ┌─────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
app | │ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
app | ├─────┼───────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
app | │ 0 │ App │ default │ 1.0.0 │ cluster │ 36 │ 0s │ 0 │ online │ 0% │ 38.0mb │ root │ disabled │
app | │ 1 │ App │ default │ 1.0.0 │ cluster │ 43 │ 0s │ 0 │ online │ 0% │ 25.0mb │ root │ disabled │
app | └─────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
And then it returns a message:
app exited with code 0
The whole process lopps over again and again and again... I tried to run it on 'cluster_mode' on 'fork', I tried to run it with --no-autorestart but it still keeps restarting.
I literally have no idea what am I doing wrong?
@@EDIT, added ecosystem.config.js
module.exports = {
apps : [{
name: 'App',
script: './build/server/index.js',
// Options reference: https://pm2.keymetrics.io/docs/usage/application-declaration/
exec_mode: 'cluster_mode',
args: 'none',
instances: os.cpus().length,
autorestart: false,
watch: false,
// max_memory_restart: '3G',
env: {
NODE_ENV:'development',
},
env_production: {
NODE_ENV:'production',
}
}],
deploy : {
production : {
user : 'szygendab',
host : '212.83.163.1',
ref : 'origin/master',
repo : 'git@github.com:repo.git',
path : '/var/www/production',
'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production'
}
}
};
