-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (22 loc) · 790 Bytes
/
server.js
File metadata and controls
28 lines (22 loc) · 790 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
const env = require("./src/config/env.config")
const dns = require("dns")
// Force IPv4 resolution to prevent connection timeouts with cloud databases in Node 17+
dns.setDefaultResultOrder('ipv4first')
const { verifyConnection } = require("./src/db")
const app = require("./src/app")
const PORT = env.PORT
async function start() {
try {
await verifyConnection()
// Start background scheduler
const SchedulerService = require("./src/services/scheduler.service");
SchedulerService.start();
app.listen(PORT, "0.0.0.0", () => {
console.log(`Server is running on http://0.0.0.0:${PORT}`)
})
} catch (error) {
console.error("Failed to start server:", error.message)
process.exit(1)
}
}
start()