Add analysis trigger
This commit is contained in:
@@ -21,11 +21,11 @@ export class DailyS3Scheduler {
|
||||
}
|
||||
|
||||
// Test S3 connection before starting scheduler
|
||||
const connectionTest = await this.s3Sync.testConnection();
|
||||
if (!connectionTest) {
|
||||
logger.error("S3 connection test failed. S3 sync scheduler will not be started.");
|
||||
return;
|
||||
}
|
||||
// const connectionTest = await this.s3Sync.testConnection();
|
||||
// if (!connectionTest) {
|
||||
// logger.error("S3 connection test failed. S3 sync scheduler will not be started.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Cron expression for midnight PST
|
||||
// Note: This uses PST timezone. During PDT (daylight time), it will still run at midnight local time
|
||||
@@ -35,10 +35,11 @@ export class DailyS3Scheduler {
|
||||
this.cronJob = cron.schedule(
|
||||
cronExpression,
|
||||
async () => {
|
||||
await this.performDailySync();
|
||||
//await this.performDailySync();
|
||||
await this.triggerJobAnalysis();
|
||||
},
|
||||
{
|
||||
timezone: timezone,
|
||||
timezone: timezone
|
||||
}
|
||||
);
|
||||
|
||||
@@ -92,6 +93,21 @@ export class DailyS3Scheduler {
|
||||
await this.performDailySync();
|
||||
}
|
||||
|
||||
async triggerJobAnalysis(): Promise<void> {
|
||||
if (!this.s3Sync) {
|
||||
logger.error("S3 sync not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("Triggering jobs directory analysis...");
|
||||
try {
|
||||
const analysis = await this.s3Sync.analyzeJobsDirectory();
|
||||
logger.info("Jobs directory analysis completed:", analysis);
|
||||
} catch (error) {
|
||||
logger.error("Jobs directory analysis failed:", error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next scheduled run time
|
||||
*/
|
||||
@@ -103,7 +119,7 @@ export class DailyS3Scheduler {
|
||||
// Create a date object for midnight PST today
|
||||
const now = new Date();
|
||||
const pstNow = new Date(now.toLocaleString("en-US", { timeZone: "America/Los_Angeles" }));
|
||||
|
||||
|
||||
// If it's past midnight today, next run is tomorrow at midnight
|
||||
const nextRun = new Date(pstNow);
|
||||
if (pstNow.getHours() > 0 || pstNow.getMinutes() > 0 || pstNow.getSeconds() > 0) {
|
||||
@@ -111,7 +127,7 @@ export class DailyS3Scheduler {
|
||||
}
|
||||
nextRun.setHours(0, 0, 0, 0);
|
||||
|
||||
return nextRun.toLocaleString("en-US", {
|
||||
return nextRun.toLocaleString("en-US", {
|
||||
timeZone: "America/Los_Angeles",
|
||||
weekday: "long",
|
||||
year: "numeric",
|
||||
@@ -145,10 +161,10 @@ export class DailyS3Scheduler {
|
||||
isConfigured: this.s3Sync !== null,
|
||||
isRunning: this.cronJob !== null,
|
||||
nextRun: this.getNextRunTime(),
|
||||
syncStats,
|
||||
syncStats
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Export a singleton instance
|
||||
export const dailyS3Scheduler = new DailyS3Scheduler();
|
||||
export const dailyS3Scheduler = new DailyS3Scheduler();
|
||||
|
||||
Reference in New Issue
Block a user