-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
31 lines (28 loc) · 966 Bytes
/
main.js
File metadata and controls
31 lines (28 loc) · 966 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
const cron = require("node-cron");
const logger = require("./src/utils/logging/winston");
const { startMetricsServer } = require("./src/server/metricsServer");
const { updateAllMetars } = require("./src/services/metar/metarUpdater");
const {
performStartupChecks,
scheduleHealthChecks,
} = require("./src/services/health/healthChecker");
const { handleShutdown } = require("./src/utils/lifecycle");
const { initRedis } = require("./src/cache/redisClient");
const startApplication = async () => {
try {
startMetricsServer();
await initRedis();
await performStartupChecks();
await updateAllMetars();
cron.schedule("*/5 * * * *", updateAllMetars);
scheduleHealthChecks(cron);
logger.info("METAR monitoring active");
} catch (error) {
logger.error("Application startup failed", { error: error.message });
process.exit(1);
}
};
// Handle application shutdown
handleShutdown();
// Start the application
startApplication();