-
Notifications
You must be signed in to change notification settings - Fork 67
/
server.js
34 lines (27 loc) · 967 Bytes
/
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
/* eslint-disable no-unused-vars */
/* eslint-disable no-console */
require('dotenv').config({
path: './config.env',
});
const app = require('./app');
const Cronjob = require('./controllers/cronController');
// const { SyncJob } = require('./controllers/cronController');
const { sync } = require('./controllers/syncController');
const logger = require('./utils/logger.js');
const PORT = process.env.PORT || 22668;
Cronjob();
sync();
// SyncJob(); It throws an error saying "syncJob is not a function"
const server = app.listen(PORT, () => console.log(`Server is running on ${PORT}`));
process.on('unhandledRejection', (reason, promise) => {
logger.error(`Unhandled rejection at ${promise}, reason: ${reason.message}`);
server.close(() => {
process.exit(1);
});
});
process.on('SIGTERM', () => {
logger.info('SIGTERM Received, Shutting down gracefully');
server.close(() => {
logger.info('Process Terminated because of SIGTERM');
});
});