mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
fix(pm2): debug and examples for pm2
This commit is contained in:
parent
78d9e3568e
commit
082f0ccede
@ -9,7 +9,8 @@ log4js.configure({
|
||||
categories: {
|
||||
default: { appenders: ['out'], level: 'info' }
|
||||
},
|
||||
pm2: true
|
||||
pm2: true,
|
||||
pm2InstanceVar: 'INSTANCE_ID'
|
||||
});
|
||||
|
||||
const logger = log4js.getLogger('app');
|
||||
|
||||
9
examples/pm2.json
Normal file
9
examples/pm2.json
Normal file
@ -0,0 +1,9 @@
|
||||
{ "apps": [
|
||||
{ "name": "testing",
|
||||
"script": "pm2.js",
|
||||
"instances": 0,
|
||||
"instance_var": "INSTANCE_ID",
|
||||
"exec_mode": "cluster"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -76,6 +76,10 @@ class Configuration {
|
||||
debug(`DEPRECATION: Appender ${config.type} exports a shutdown function.`);
|
||||
}
|
||||
|
||||
debug(`cluster.isMaster ? ${cluster.isMaster}`);
|
||||
debug(`pm2 enabled ? ${this.pm2}`);
|
||||
debug(`pm2InstanceVar = ${this.pm2InstanceVar}`);
|
||||
debug(`process.env[${this.pm2InstanceVar}] = ${process.env[this.pm2InstanceVar]}`);
|
||||
if (cluster.isMaster || (this.pm2 && process.env[this.pm2InstanceVar] === '0')) {
|
||||
return appenderModule.configure(
|
||||
config,
|
||||
|
||||
@ -303,7 +303,7 @@ test('log4js configuration validation', (batch) => {
|
||||
'/var/lib/cheese/cheese': testAppender('correct'),
|
||||
},
|
||||
globals: {
|
||||
process: { cwd: () => '/var/lib/cheese' }
|
||||
process: { cwd: () => '/var/lib/cheese', env: {} }
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user