mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #738 from log4js-node/passenger-fix
fix: #525 disableClustering broken on passenger
This commit is contained in:
commit
0735e55a37
@ -211,7 +211,7 @@ function configure(configurationFileOrObject) {
|
||||
|
||||
// just in case configure is called after shutdown
|
||||
process.removeListener('message', receiver);
|
||||
if (cluster) {
|
||||
if (cluster && !config.disableClustering) {
|
||||
cluster.removeListener('message', receiver);
|
||||
}
|
||||
if (config.disableClustering) {
|
||||
|
||||
51
test/tap/passenger-test.js
Normal file
51
test/tap/passenger-test.js
Normal file
@ -0,0 +1,51 @@
|
||||
const test = require('tap').test;
|
||||
const sandbox = require('sandboxed-module');
|
||||
|
||||
// passenger provides a non-functional cluster module,
|
||||
// but it does not implement the event emitter functions
|
||||
// this is taken from https://github.com/phusion/passenger/blob/82bef697c0019c034faeb9b0f8c08a43ec4e1e22/src/helper-scripts/node-loader.js#L64
|
||||
const passengerCluster = {
|
||||
disconnect: function () { return false; },
|
||||
fork: function () { return false; },
|
||||
setupMaster: function () { return false; },
|
||||
isWorker: true,
|
||||
isMaster: false,
|
||||
schedulingPolicy: false,
|
||||
settings: false,
|
||||
worker: false,
|
||||
workers: false,
|
||||
};
|
||||
|
||||
const vcr = require('../../lib/appenders/recording');
|
||||
|
||||
const log4js = sandbox.require(
|
||||
'../../lib/log4js',
|
||||
{
|
||||
requires: {
|
||||
cluster: passengerCluster,
|
||||
'./appenders/recording': vcr
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
test('When running in Passenger', (batch) => {
|
||||
batch.test('it should still log', (t) => {
|
||||
log4js.configure({
|
||||
appenders: {
|
||||
vcr: { type: 'recording' }
|
||||
},
|
||||
categories: {
|
||||
default: { appenders: ['vcr'], level: 'info' }
|
||||
},
|
||||
disableClustering: true
|
||||
});
|
||||
log4js.getLogger().info('This should still work');
|
||||
|
||||
const events = vcr.replay();
|
||||
t.equal(events.length, 1);
|
||||
t.equal(events[0].data[0], 'This should still work');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.end();
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user