Reputation: 4585
I'm still quite new to pm2 and currently trying to get a node app running. This workes fine except the fact that the app gets restarted without any reason.
The app runs fine without any crash on the development machine. The log files do not show any crash. (Already testet that the log files would log a crash.)
Did I configure pm2 wrong?
{
"name" : "app1",
"cwd" : "/home/pm2/apps/app1/prod",
"script" : "dist/main.js",
"log_date_format" : "YYYY-MM-DD HH:mm Z",
"error_file" : "/home/pm2/apps/app1/logs/stderr.log",
"out_file" : "/home/pm2/apps/app1/logs/stdout.log",
"pid_file" : "/home/pm2/apps/app1/pids/app1.pid",
"instances" : 1, //or 0 => 'max'
"min_uptime" : "200s", // 200 seconds, defaults to 1000
"max_restarts" : 10, // defaults to 15
"max_memory_restart": "1M", // 1 megabytes, e.g.: "2G", "10M", "100K", 1024 the default unit is byte.
"cron_restart" : "1 0 * * *",
"watch" : false,
"ignore_watch" : "./logs",
"exec_interpreter" : "node",
"env": {
"NODE_ENV": "production"
}
}
2016-10-24 14:28 +02:00: server listening on port 3100
2016-10-24 14:28 +02:00: server listening on port 3100
2016-10-24 14:29 +02:00: server listening on port 3100
2016-10-24 14:29 +02:00: server listening on port 3100
2016-10-24 14:30 +02:00: server listening on port 3100
2016-10-24 14:30 +02:00: server listening on port 3100
//empty...
Upvotes: 1
Views: 1420
Reputation: 1939
This directive could be problem: 'max_memory_restart'. One megabyte for app is pretty low value. Try to increase to ~200MB - depending on your app memory requirements.
EDIT: this directive is expressing maximum amount of memory which can be consumpted. If process will allocate more, it will be restarted.
Upvotes: 5