-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (31 loc) · 963 Bytes
/
Copy pathserver.js
File metadata and controls
38 lines (31 loc) · 963 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
27
28
29
30
31
32
33
34
35
36
37
38
require('dotenv').config()
const http = require('http')
const app = require('./src')
const sequelize = require('./src/config/db')
const {setupNotificationScheduler} = require('./src/services/schedulerService')
// const logger = require('./src/config/log')
process.on('uncaughtException', err => {
console.error(err.name, err.message)
console.error('UNCAUGHT EXCEPTION! 💥 Shutting down...')
process.exit(1)
})
const PORT = process.env.PORT || 3000
const HOST = '0.0.0.0'
const server = http.createServer(app)
sequelize
.sync()
.then(() =>
server.listen(PORT, HOST, () => {
console.info(`Server is running at ${HOST}:${PORT}`)
// Set up scheduler
setupNotificationScheduler()
})
)
.catch(err => {
console.error('❌ Unable to connect:', err)
})
process.on('unhandledRejection', err => {
console.error(err.name, err.message)
console.error('UNHANDLED REJECTION! 💥 Shutting down...')
process.exit(1)
})