From 2c6a87eb7ccb382beb84ad0ca440e4aff572b42e Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Thu, 26 Oct 2017 10:21:32 +0300 Subject: [PATCH] updated config handler --- config/default.toml | 3 +++ config/plugins/example.toml | 10 ++++++++++ lib/plugins.js | 12 ++++++++++++ package.json | 10 +++++----- worker.js | 12 ++++++++++-- 5 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 config/plugins/example.toml create mode 100644 lib/plugins.js diff --git a/config/default.toml b/config/default.toml index cf74eb0a..e4305eef 100644 --- a/config/default.toml +++ b/config/default.toml @@ -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" diff --git a/config/plugins/example.toml b/config/plugins/example.toml new file mode 100644 index 00000000..11718a46 --- /dev/null +++ b/config/plugins/example.toml @@ -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" diff --git a/lib/plugins.js b/lib/plugins.js new file mode 100644 index 00000000..2fc5102f --- /dev/null +++ b/lib/plugins.js @@ -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); +}; diff --git a/package.json b/package.json index d73181bf..b6f842a0 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/worker.js b/worker.js index b85be7ac..1a1640ce 100644 --- a/worker.js +++ b/worker.js @@ -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'); + }); }); }); });