add assigned field

This commit is contained in:
Andris Reinman 2017-08-29 10:36:45 +03:00
parent b0ad888622
commit 6e30b385e8
6 changed files with 43 additions and 7 deletions

View file

@ -25,6 +25,8 @@ maxForwards=2000
# If usernames are not email addresses then use this domain as hostname part
#emailDomain="mydomain.info"
bugsnagCode=""
[dbs]
# @include "dbs.toml"

17
lib/errors.js Normal file
View file

@ -0,0 +1,17 @@
/* eslint global-require: 0 */
'use strict';
const config = require('wild-config');
let bugsnag;
if (config.bugsnagCode) {
bugsnag = require('bugsnag');
bugsnag.register(config.bugsnagCode);
bugsnag.notify(new Error('Non-fatal'));
}
module.exports.notify = (...args) => {
if (bugsnag) {
bugsnag.notify(...args);
}
};

View file

@ -219,6 +219,8 @@ module.exports = (options, callback) => {
domain: recipientDomain,
sendingZone: deliveryZone,
assigned: 'no',
// actual recipient address
recipient: recipient.to,
http: recipient.http,

View file

@ -25,6 +25,7 @@
"dependencies": {
"addressparser": "^1.0.1",
"bcryptjs": "^2.4.3",
"bugsnag": "^1.12.0",
"generate-password": "^1.3.0",
"he": "^1.1.1",
"html-to-text": "^3.3.0",

View file

@ -5,6 +5,7 @@
process.env.UV_THREADPOOL_SIZE = 16;
const config = require('wild-config');
const errors = require('./lib/errors');
const fs = require('fs');
const log = require('npmlog');
const packageData = require('./package.json');
@ -74,3 +75,8 @@ if (!config.processes || config.processes <= 1) {
require('./worker.js');
}
}
process.on('unhandledRejection', err => {
log.error('App', 'Unhandled rejection: %s' + ((err && err.stack) || err));
errors.notify(err);
});

View file

@ -7,6 +7,7 @@ const pop3 = require('./pop3');
const lmtp = require('./lmtp');
const api = require('./api');
const db = require('./lib/db');
const errors = require('./lib/errors');
// preload certificate files
require('./lib/certs');
@ -15,32 +16,37 @@ require('./lib/certs');
db.connect(err => {
if (err) {
log.error('Db', 'Failed to setup database connection');
return process.exit(1);
errors.notify(err);
return setTimeout(() => process.exit(1), 3000);
}
// Start IMAP server
imap(err => {
if (err) {
log.error('App', 'Failed to start IMAP server. %s', err.message);
return process.exit(1);
errors.notify(err);
return setTimeout(() => process.exit(1), 3000);
}
// Start POP3 server
pop3(err => {
if (err) {
log.error('App', 'Failed to start POP3 server');
return process.exit(1);
errors.notify(err);
return setTimeout(() => process.exit(1), 3000);
}
// Start LMTP maildrop server
lmtp(err => {
if (err) {
log.error('App', 'Failed to start LMTP server');
return process.exit(1);
errors.notify(err);
return setTimeout(() => process.exit(1), 3000);
}
// Start HTTP API server
api(err => {
if (err) {
log.error('App', 'Failed to start API server');
return process.exit(1);
errors.notify(err);
return setTimeout(() => process.exit(1), 3000);
}
log.info('App', 'All servers started, ready to process some mail');
@ -52,7 +58,8 @@ db.connect(err => {
log.info('App', 'Changed group to "%s" (%s)', config.group, process.getgid());
} catch (E) {
log.error('App', 'Failed to change group to "%s" (%s)', config.group, E.message);
return process.exit(1);
errors.notify(E);
return setTimeout(() => process.exit(1), 3000);
}
}
if (config.user) {
@ -61,7 +68,8 @@ db.connect(err => {
log.info('App', 'Changed user to "%s" (%s)', config.user, process.getuid());
} catch (E) {
log.error('App', 'Failed to change user to "%s" (%s)', config.user, E.message);
return process.exit(1);
errors.notify(E);
return setTimeout(() => process.exit(1), 3000);
}
}
});