forked from CBIIT/CCDC-WebService
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (30 loc) · 936 Bytes
/
app.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
const express = require("express");
const config = require("./Config");
const logger = require("./Components/logger");
const elasticsearch = require("./Components/elasticsearch");
const app = express();
require("./Config/express")(app);
const startServer = async () => {
try {
// Test Elasticsearch connection
const elasticsearchConnected = await elasticsearch.testConnection();
if (elasticsearchConnected) {
logger.info("Elasticsearch connected!");
} else {
logger.info("Failed to connect to Elasticsearch.");
}
// Start server
app.listen(config.port, () => {
logger.info("Server listening on %d, in %s mode", config.port, config.env);
});
} catch (error) {
logger.error("Error starting server:", error);
}
};
// Start the server
startServer();
// Handle graceful shutdown
process.on("SIGINT", () => {
logger.info("Gracefully shutting down :)");
process.exit();
});