Skip to content

Commit

Permalink
Merge pull request #4624 from cloud-gov/chore-separate-nightly-schedu…
Browse files Browse the repository at this point in the history
…led-processors

chore: separate nightly tasks
  • Loading branch information
drewbo authored Oct 17, 2024
2 parents 4ef376d + 10231df commit cd4f911
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions api/workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ const Mailer = require('./Mailer');
const QueueWorker = require('./QueueWorker');

const EVERY_TEN_MINUTES_CRON = '0,10,20,30,40,50 * * * *';
const NIGHTLY_CRON = '0 5 * * *';

const everyTenMinutesJobConfig = {
repeat: { cron: EVERY_TEN_MINUTES_CRON },
priority: 1,
};

const nightlyJobConfig = {
repeat: { cron: NIGHTLY_CRON },
const makeNightlyJobConfig = (minute = 0, hour = 5) => ({
repeat: { cron: `'${minute} ${hour} * * *'` },
priority: 10,
};
});

function pagesWorker(connection) {
const domainJobProcessor = (job) => {
Expand Down Expand Up @@ -116,12 +115,12 @@ function pagesWorker(connection) {
];

const jobs = () => Promise.all([
archiveBuildLogsQueue.add('archiveBuildLogsDaily', {}, nightlyJobConfig),
archiveBuildLogsQueue.add('archiveBuildLogsDaily', {}, makeNightlyJobConfig(30, 4)),
failStuckBuildsQueue.add('failStuckBuilds', {}, everyTenMinutesJobConfig),
nightlyBuildsQueue.add('nightlyBuilds', {}, nightlyJobConfig),
scheduledQueue.add('sandboxNotifications', {}, nightlyJobConfig),
scheduledQueue.add('cleanSandboxOrganizations', {}, nightlyJobConfig),
scheduledQueue.add('buildTasksScheduler', {}, nightlyJobConfig),
nightlyBuildsQueue.add('nightlyBuilds', {}, makeNightlyJobConfig(0, 5)),
scheduledQueue.add('sandboxNotifications', {}, makeNightlyJobConfig(30, 5)),
scheduledQueue.add('cleanSandboxOrganizations', {}, makeNightlyJobConfig(30, 5)),
scheduledQueue.add('buildTasksScheduler', {}, makeNightlyJobConfig(0, 6)),
timeoutBuildTasksQueue.add('timeoutBuilds', {}, everyTenMinutesJobConfig),
]);

Expand Down

0 comments on commit cd4f911

Please sign in to comment.