Skip to content

Commit

Permalink
fix overwrite logs in cluster mode
Browse files Browse the repository at this point in the history
  • Loading branch information
EllieSummer committed May 24, 2019
1 parent 36b3794 commit 67b8952
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
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

1 comment on commit 67b8952

@shubham-rapidops
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this done? I have a process that runs in multiple instances now it only rotates one of them and the others are not rotated due to which server memory gets filled.

Please sign in to comment.