Skip to content

Commit

Permalink
Merge pull request #129 from EllieSummer/patch-1
Browse files Browse the repository at this point in the history
fix overwrite logs in cluster mode
  • Loading branch information
Unitech committed Oct 11, 2019
2 parents eb3aa14 + 67b8952 commit 9a98ad6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app.js
Expand Up @@ -199,10 +199,16 @@ pm2.connect(function(err) {
pm2.list(function(err, apps) {
if (err) return console.error(err.stack || err);

var appMap = {};
// rotate log that are bigger than the limit
apps.forEach(function(app) {
// if its a module and the rotate of module is disabled, ignore
if (typeof(app.pm2_env.axm_options.isModule) !== 'undefined' && !ROTATE_MODULE) return ;

// if apps instances are multi and one of the instances has rotated, ignore
if(app.pm2_env.instances > 1 && appMap[app.name]) return;

appMap[app.name] = app;

proceed_app(app, false);
});
Expand All @@ -219,11 +225,17 @@ pm2.connect(function(err) {
pm2.list(function(err, apps) {
if (err) return console.error(err.stack || err);

var appMap = {};
// force rotate for each app
apps.forEach(function(app) {
// if its a module and the rotate of module is disabled, ignore
if (typeof(app.pm2_env.axm_options.isModule) !== 'undefined' && !ROTATE_MODULE) return ;

// if apps instances are multi and one of the instances has rotated, ignore
if(app.pm2_env.instances > 1 && appMap[app.name]) return;

appMap[app.name] = app;

proceed_app(app, true);
});
});
Expand Down

0 comments on commit 9a98ad6

Please sign in to comment.