updated config handler

This commit is contained in:
Andris Reinman 2017-10-26 10:21:32 +03:00
parent 29c4d22635
commit 2c6a87eb7c
5 changed files with 40 additions and 7 deletions

View file

@ -76,6 +76,9 @@ bugsnagCode=""
[sender]
# @include "sender.toml"
[plugins]
# @include "plugins/*.toml"
[smtp.setup]
# Public configuration for SMTP MDA, needed for mobileconfig files
hostname="localhost"

View file

@ -0,0 +1,10 @@
[example]
name="Example Plugin"
# $WD: path of wildduck module root
# $CONFIG: path of config root
path="$WD/plugins/example.js"
# Additional config options
value1 = "Example config option"

12
lib/plugins.js Normal file
View file

@ -0,0 +1,12 @@
'use strict';
const config = require('wild-config');
const pathlib = require('path');
const WD_PATH = pathlib.join(__dirname, '..');
const CONFIG_PATH = pathlib.join(__dirname, '..');
module.exports = next => {
console.log(config);
setImmediate(next);
};

View file

@ -27,7 +27,7 @@
"dependencies": {
"addressparser": "1.0.1",
"bcryptjs": "2.4.3",
"bugsnag": "2.0.0",
"bugsnag": "2.0.1",
"generate-password": "1.3.0",
"he": "1.1.1",
"html-to-text": "3.3.0",
@ -35,7 +35,7 @@
"humanparser": "1.5.0",
"iconv-lite": "0.4.19",
"ioredfour": "1.0.2-ioredis",
"ioredis": "3.1.4",
"ioredis": "3.2.1",
"joi": "13.0.1",
"js-yaml": "3.10.0",
"libbase64": "0.2.0",
@ -46,7 +46,7 @@
"mobileconfig": "2.1.0",
"mongo-cursor-pagination": "5.0.0",
"mongodb": "2.2.33",
"nodemailer": "4.2.0",
"nodemailer": "4.3.1",
"npmlog": "4.1.2",
"openpgp": "2.5.12",
"qrcode": "0.9.0",
@ -54,11 +54,11 @@
"seq-index": "1.1.0",
"smtp-server": "3.3.0",
"speakeasy": "2.0.0",
"tlds": "1.198.0",
"tlds": "1.199.0",
"u2f": "^0.1.3",
"utf7": "1.0.2",
"uuid": "3.1.0",
"wild-config": "1.3.5"
"wild-config": "1.3.6"
},
"repository": {
"type": "git",

View file

@ -7,6 +7,7 @@ const pop3 = require('./pop3');
const irc = require('./irc');
const lmtp = require('./lmtp');
const api = require('./api');
const plugins = require('./lib/plugins');
const db = require('./lib/db');
const errors = require('./lib/errors');
@ -58,8 +59,6 @@ db.connect(err => {
return setTimeout(() => process.exit(1), 3000);
}
log.info('App', 'All servers started, ready to process some mail');
// downgrade user and group if needed
if (config.group) {
try {
@ -81,6 +80,15 @@ db.connect(err => {
return setTimeout(() => process.exit(1), 3000);
}
}
plugins(err => {
if (err) {
log.error('App', 'Failed to start plugins');
errors.notify(err);
return setTimeout(() => process.exit(1), 3000);
}
log.info('App', 'All servers started, ready to process some mail');
});
});
});
});