-
Notifications
You must be signed in to change notification settings - Fork 182
/
app.js
37 lines (31 loc) · 851 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const process = require('process');
const Graceful = require('@ladjs/graceful');
const ip = require('ip');
const ms = require('ms');
const ForwardEmail = require('.');
const app = new ForwardEmail();
const { logger, port } = app.config;
const graceful = new Graceful({
servers: [app.server],
redisClients: [app.client],
logger,
// smtp-server connections have 30s timeout
// this yields a +15s overhead
timeoutMs: ms('45s')
});
graceful.listen();
(async () => {
try {
await app.listen(port);
if (process.send) process.send('ready');
logger.info(
`ForwardEmail server listening on ${
app.server.address().port
} (LAN: ${ip.address()}:${app.server.address().port})`
);
} catch (err) {
logger.error(err);
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
}
})();