Skip to content

Commit c7aff66

Browse files
authored
fix: config: make bounce rules file path configurable (#484)
1 parent e1f9569 commit c7aff66

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

config/default.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const path = require('path');
4+
35
module.exports = {
46
// If started as root then privileges are dropped after all ports are bound
57
//user: 'nobody',
@@ -515,6 +517,9 @@ module.exports = {
515517
*/
516518
},
517519

520+
// Bounce rules file path
521+
bouncesFile: path.join(__dirname, 'bounces.txt'),
522+
518523
pluginsPath: './plugins',
519524
corePluginsPath: './plugins'
520525
};

lib/bounces.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
'use strict';
22

3+
const config = require('@zone-eu/wild-config');
34
const log = require('npmlog');
45
const fs = require('fs');
56
const path = require('path');
67
const { gelfCode, emitGelf } = require('./log-gelf');
8+
const DEFAULT_BOUNCES_FILE = path.join(__dirname, '..', 'config', 'bounces.txt');
79

810
function reloadBounces() {
911
let body;
12+
let bouncesFile = config.bouncesFile || DEFAULT_BOUNCES_FILE;
1013

1114
try {
12-
body = fs.readFileSync(path.join(__dirname, '..', 'config', 'bounces.txt'), 'utf-8');
15+
body = fs.readFileSync(bouncesFile, 'utf-8');
1316
} catch (E) {
1417
log.error('Bounces/' + process.pid, 'Could not load bounce rules. %s', E.message);
1518
emitGelf({
1619
short_message: `${gelfCode('BOUNCE_RULES_LOAD_FAILED')} Could not load bounce rules`,
1720
full_message: E && E.stack ? E.stack : undefined,
1821
_logger: 'Bounces/' + process.pid,
19-
_file: path.join(__dirname, '..', 'config', 'bounces.txt'),
22+
_file: bouncesFile,
2023
_error: E.message
2124
});
2225
if (module.exports.rules && module.exports.rules.length) {

0 commit comments

Comments
 (0)