-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_server.js
49 lines (41 loc) · 1.23 KB
/
http_server.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(async () => {
const { config } = require("./connections");
global.config = config();
global.SERVER_ID = global.config.SERVER_TYPE;
global.SERVER_PORT =global.config.HTTP_SERVER_PORT;
global.is_http = true;
global.is_https = false;
const { logger } = require("./src");
const { rdsOps, mongoOps, app } = require("./connections");
(async () => {
try {
const promise = await Promise.all([
mongoOps.init(),
rdsOps.init(),
]);
const mongoClient = promise[0];
const redisClient = promise[1];
global.redisClient = redisClient;
global.mongoClient = mongoClient;
app.listen(global.SERVER_PORT, () => {
logger.info(`${global.SERVER_ID} Server listening to the port ${global.SERVER_PORT}`);
});
} catch (error) {
console.trace(error);
logger.error(`Server listen error ${error}`);
}
})();
process
.on("unhandledRejection", (reason, p) => {
logger.error(
reason,
"Unhandled Rejection at Promise >> ",
new Date(),
" >> ",
p
);
})
.on("uncaughtException", (err) => {
logger.error("Uncaught Exception thrown", new Date(), " >> ", "\n", err);
});
})();