wildduck/server.js

37 lines
990 B
JavaScript
Raw Normal View History

2017-03-06 05:45:50 +08:00
'use strict';
2017-03-06 22:13:40 +08:00
let config = require('config');
let log = require('npmlog');
let imap = require('./imap');
let lmtp = require('./lmtp');
let smtp = require('./smtp');
2017-03-06 22:13:40 +08:00
let api = require('./api');
2017-03-06 05:45:50 +08:00
log.level = config.log.level;
2017-03-06 22:13:40 +08:00
imap((err, imap) => {
2017-03-06 05:45:50 +08:00
if (err) {
2017-03-06 22:13:40 +08:00
log.error('App', 'Failed to start IMAP server');
return process.exit(1);
2017-03-06 05:45:50 +08:00
}
2017-03-06 22:13:40 +08:00
lmtp(imap, err => {
if (err) {
log.error('App', 'Failed to start LMTP server');
return process.exit(1);
}
smtp(imap, err => {
2017-03-06 05:45:50 +08:00
if (err) {
log.error('App', 'Failed to start SMTP server');
2017-03-06 22:13:40 +08:00
return process.exit(1);
2017-03-06 05:45:50 +08:00
}
api(imap, err => {
if (err) {
log.error('App', 'Failed to start API server');
return process.exit(1);
}
log.info('App', 'All servers started, ready to process some mail');
});
2017-03-06 05:45:50 +08:00
});
2017-03-06 22:13:40 +08:00
});
2017-03-06 05:45:50 +08:00
});