-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.ts
35 lines (28 loc) · 935 Bytes
/
server.ts
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
// import dotenv from "dotenv";
// dotenv.config();
import { server } from "./app";
import { setupCloudinary } from "./config/cloudinary";
import { connectDB } from "./config/database";
// DB Connection
connectDB();
//Cloudinary Setup
setupCloudinary();
server.listen(process.env.PORT, () => console.log(`Server is running at port ${process.env.PORT}`));
process.on("uncaughtException", (err: any) => {
console.log("UNCAUGHT EXCEPTION! 🔥 Shutting down...");
console.log(err.name, err.message);
process.exit(1);
});
process.on("unhandledRejection", (err: any) => {
console.log("UNHANDLED REJECTION! 💥 Shutting down...");
console.log(err.name, err.message);
server.close(() => {
process.exit(1);
});
});
process.on("SIGTERM", () => {
console.log("👋 SIGTERM RECEIVED. Shutting down gracefully");
server.close(() => {
console.log("💥 Process terminated!");
});
});