Skip to content

Commit 40a75a7

Browse files
committed
move server start out of event handler
1 parent 1e528af commit 40a75a7

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

middleware/logger.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
import pino from 'pino';
22

3-
const env = process.env.NODE_ENV;
4-
const isLocal = (env !== 'production' || env !== 'stage');
5-
6-
export default isLocal ? pino() : pino();
3+
export default pino();

server.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,18 @@ const gracefulShutdown = (msg) => {
2020
};
2121

2222
// Server start
23-
app.on('ready', () => {
24-
SERVER.listen(PORT, '0.0.0.0', () => {
25-
logger.info(`Running on port: ${PORT}`);
23+
SERVER.listen(PORT, '0.0.0.0', () => {
24+
logger.info(`Running on port: ${PORT}`);
2625

27-
// Handle kill commands
28-
process.on('SIGTERM', gracefulShutdown);
26+
// Handle kill commands
27+
process.on('SIGTERM', gracefulShutdown);
2928

30-
// Handle interrupts
31-
process.on('SIGINT', gracefulShutdown);
29+
// Handle interrupts
30+
process.on('SIGINT', gracefulShutdown);
3231

33-
// Prevent dirty exit on uncaught exceptions:
34-
process.on('uncaughtException', gracefulShutdown);
32+
// Prevent dirty exit on uncaught exceptions:
33+
process.on('uncaughtException', gracefulShutdown);
3534

36-
// Prevent dirty exit on unhandled promise rejection
37-
process.on('unhandledRejection', gracefulShutdown);
38-
});
35+
// Prevent dirty exit on unhandled promise rejection
36+
process.on('unhandledRejection', gracefulShutdown);
3937
});

0 commit comments

Comments
 (0)