-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (21 loc) · 750 Bytes
/
server.js
File metadata and controls
25 lines (21 loc) · 750 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
const app = require("./app");
const dotenv = require("dotenv");
dotenv.config({path:"config/config.env"});
require("./database/conn");
const port = 4000 || process.env.PORT;
process.on("unhandledRejection",(err)=>{
console.log(`Error: ${err.message}`);
console.log(`Shutting down the Server due to unHandled Promise Rejection`);
server.close(()=>{
process.exit(1);
});
});
//handling uncaughtException
process.on("uncaughtException" , (err)=>{
console.log(`Error: ${err.message}`);
console.log(`Shutting down the Server due to unCaughtException `);
process.exit(1);
})
const server = app.listen(port,()=>{ // find why we are using const server here.
console.log(`Server is running at port : ${port}`);
})