Skip to content

Commit

Permalink
feat: sensible cron timing for syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
JustSamuel committed Jan 19, 2025
1 parent 732e5a9 commit 1c88b3d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function createCronTasks(): Promise<void> {
syncServices.push(ldapSyncService);
}

if (process.env.GEWISDB_API_KEY && process.env.GEWISDB_API_URL && process.env.ENABLE_GEWISDB_SYNC) {
if (process.env.GEWISDB_API_KEY && process.env.GEWISDB_API_URL && process.env.ENABLE_GEWISDB_SYNC === 'true') {
const gewisDBSyncService = new GewisDBSyncService();
syncServices.push(gewisDBSyncService);
}
Expand All @@ -119,12 +119,17 @@ async function createCronTasks(): Promise<void> {
const syncManager = new UserSyncManager(syncServices);

// TODO sensible cron schedule
const userSyncer = cron.schedule('*/10 * * * *', async () => {
const userSyncer = cron.schedule('41 1 * * *', async () => {
logger.debug('Syncing users.');
await syncManager.run();
await syncManager.fetch();
});
application.tasks.push(userSyncer);

const userFetcher = cron.schedule('*/15 * * * *', async () => {
logger.debug('Fetching users.');
await syncManager.fetch();
});
application.tasks.push(userFetcher);
}

application.logger.info('Tasks registered');
Expand Down

0 comments on commit 1c88b3d

Please sign in to comment.