Add debug logging for worker initialization and heartbeat checks

This commit is contained in:
Simon Larsen 2024-09-20 11:07:35 +01:00
parent af177d0569
commit 21ea8d0aa2
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
3 changed files with 74 additions and 45 deletions

View File

@ -14,11 +14,15 @@ const APP_NAME: string = "worker";
const init: PromiseVoidFunction = async (): Promise<void> => {
try {
logger.debug("Initializing Worker");
// Initialize telemetry
Telemetry.init({
serviceName: APP_NAME,
});
logger.debug("Telemetry initialized");
const statusCheck: PromiseVoidFunction = async (): Promise<void> => {
// Check the status of infrastructure components
return await InfrastructureStatus.checkStatus({
@ -37,27 +41,43 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
},
});
logger.debug("App initialized");
// Connect to Postgres database
await PostgresAppInstance.connect();
logger.debug("Postgres connected");
// Connect to Redis
await Redis.connect();
logger.debug("Redis connected");
// Connect to Clickhouse database
await ClickhouseAppInstance.connect(
ClickhouseAppInstance.getDatasourceOptions(),
);
logger.debug("Clickhouse connected");
// Initialize real-time functionalities
await Realtime.init();
logger.debug("Realtime initialized");
// Initialize home routes at the end since it has a catch-all route
await WorkerRoutes.init();
logger.debug("Routes initialized");
// Add default routes to the app
await App.addDefaultRoutes();
logger.debug("Default routes added");
logger.info("Worker Initialized Successfully");
} catch (err) {
logger.error("App Init Failed:");
logger.error("Worker Init Failed:");
logger.error(err);
throw err;
}

View File

@ -101,6 +101,10 @@ RunCron(
continue;
}
logger.debug(
`Updating incoming request monitor heartbeat checked at: ${monitor.id?.toString()}`,
);
await MonitorService.updateOneById({
id: monitor.id!,
data: {

View File

@ -15,6 +15,7 @@ RunCron(
"ServerMonitor:CheckOnlineStatus",
{ schedule: EVERY_MINUTE, runOnStartup: false },
async () => {
try {
const twoMinsAgo: Date = OneUptimeDate.getSomeMinutesAgo(2);
const serverMonitors: Array<Monitor> = await MonitorService.findBy({
@ -64,6 +65,10 @@ RunCron(
logger.error(error);
}
}
} catch (error) {
logger.error("Error in ServerMonitor:CheckOnlineStatus");
logger.error(error);
}
},
);