-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (24 loc) · 730 Bytes
/
Copy pathserver.js
File metadata and controls
29 lines (24 loc) · 730 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
require('dotenv').config();
const app = require('./app');
const config = require('./config/config');
const port = process.env.PORT || config.port;
// Server
const server = app.listen(port, () =>
console.log(`Server is listening at http://localhost:${port}`),
);
// Handle unhandled rejections
process.on('unhandledRejection', (err) => {
console.error('UNHANDLED REJECTION! 💥 Shutting down...');
console.error(err.name, err.message);
server.close(() => {
process.exit(1);
});
});
// Handle uncaught exceptions
process.on('uncaughtException', (err) => {
console.error('UNCAUGHT EXCEPTION! 💥 Shutting down...');
console.error(err.name, err.message);
server.close(() => {
process.exit(1);
});
});