You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Option --auto-exit only works when PM2 daemon is running well.
However, in my cases, PM2 daemon crashed for some reason, and pm2-docker process remained running. This is not normal and make my docker container still alive but no application is actually working.
I debugged in the source code of pm2-docker.js and found out. Original codes
function autoExit() {
setTimeout(function() {
pm2.list(function(err, apps) {
if (err) console.error(err.stack || err);
var online_count = 0;
apps.forEach(function(app) {
if (app.pm2_env.status == cst.ONLINE_STATUS ||
app.pm2_env.status == cst.LAUNCHING_STATUS)
online_count++;
});
if (online_count == 0) {
console.log('0 application online, exiting');
exitPM2();
}
autoExit();
});
}, 3000);
}
When PM2 daemon is dead, pm2.list won't trigger any exception but the callback function will not be called too, so pm2-docker process remains without any actual service running.
Here is my modification:
function autoExit() {
var interval = 3000;
var aliveInterval = interval * 1.5;
setTimeout(function() {
var alive = false
var aliveTimer = setTimeout(function() {
if (!alive) {
console.error('PM2 Daemon is dead');
process.exit(1);
}
}, aliveInterval);
pm2.list(function(err, apps) {
if (err) {
console.log('pm2.list got error')
console.error(err.stack || err);
exitPM2();
}
clearTimeout(aliveTimer);
alive = true;
var online_count = 0;
apps.forEach(function(app) {
if (app.pm2_env.status == cst.ONLINE_STATUS ||
app.pm2_env.status == cst.LAUNCHING_STATUS)
online_count++;
});
if (online_count == 0) {
console.log('0 application online, exiting');
exitPM2();
}
autoExit();
});
}, interval);
}
The text was updated successfully, but these errors were encountered:
PM2 version: v2.4.6
Option --auto-exit only works when PM2 daemon is running well.
However, in my cases, PM2 daemon crashed for some reason, and pm2-docker process remained running. This is not normal and make my docker container still alive but no application is actually working.
I debugged in the source code of pm2-docker.js and found out.
Original codes
When PM2 daemon is dead, pm2.list won't trigger any exception but the callback function will not be called too, so pm2-docker process remains without any actual service running.
Here is my modification:
The text was updated successfully, but these errors were encountered: