-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (26 loc) · 778 Bytes
/
index.js
File metadata and controls
33 lines (26 loc) · 778 Bytes
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
import 'dotenv/config';
import app from './app';
const { log, error } = console;
process.on('uncaughtException', (err) => {
error('UNCAUGHT EXCEPTION 💥 Shutting down server...');
error(`${err.name}:`, err);
process.exit(1);
});
const port = process.env.PORT || 3000;
const server = app.listen(port, () =>
log(
`Server is running in ${process.env.NODE_ENV} 🚀 on port ${
server.address().port
}`,
),
);
process.on('unhandledRejection', (err) => {
error('UNHANDLED REJECTION 💥 Shutting down server...');
error(`${err.name}:`, err);
server.close(() => process.exit(1));
});
process.on('SIGTERM', () => {
log('SIGTERM SIGNAL RECEIVED 👋 Shutting down gracefully...');
server.close(() => log('💥 Process terminated!'));
});
export default server;