-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (23 loc) · 699 Bytes
/
server.js
File metadata and controls
26 lines (23 loc) · 699 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
const app = require("./app")
require("dotenv").config()
const PORT = process.env.PORT
const logger = require("./utils/logger")
const Cache = require("./configs/redis")
// UNCAUGHT EXCEPTION
process.on("uncaughtException", (error, origin) => {
logger.error("UNCAUGHT EXCEPTION! 🔥 Shutting Down...")
logger.error(error.name, error.message)
process.exit(1)
})
const server = app.listen(PORT, () => {
Cache.connect()
logger.info(`server listening on port ${PORT}...`)
})
//UNHANDLED REJECTION
process.on("unhandledRejection", (reason) => {
logger.error("UNHANDLED REJECTION! 🔥 Shutting Down...")
logger.error({ REASON: reason })
server.close(() => {
process.exit(1)
})
})