Skip to content

Commit

Permalink
chore: update chron schedules so jobs don't overlap (#1857)
Browse files Browse the repository at this point in the history
  • Loading branch information
1emu authored Jun 13, 2024
1 parent 9f8efb9 commit d76c1cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/back/jobs/BadgeAirdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import logger from '../../utils/logger'
import AirdropJobModel, { AirdropJobAttributes } from '../models/AirdropJob'
import { AirdropJobStatus } from '../types/AirdropJob'

export async function runAirdropJobs() {
await Promise.all([runQueuedAirdropJobs(), giveAndRevokeLandOwnerBadges()])
}

export async function runQueuedAirdropJobs() {
const pendingJobs = await AirdropJobModel.getPending()
if (pendingJobs.length === 0) {
Expand Down
11 changes: 6 additions & 5 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { register } from 'prom-client'
import swaggerUi from 'swagger-ui-express'
import YAML from 'yaml'

import { giveTopVoterBadges, runAirdropJobs } from './back/jobs/BadgeAirdrop'
import { giveAndRevokeLandOwnerBadges, giveTopVoterBadges, runQueuedAirdropJobs } from './back/jobs/BadgeAirdrop'
import { pingSnapshot } from './back/jobs/PingSnapshot'
import { withLock } from './back/jobs/jobLocks'
import airdrops from './back/routes/airdrop'
Expand Down Expand Up @@ -50,10 +50,11 @@ jobs.cron('@eachMinute', finishProposal)
jobs.cron('@eachMinute', activateProposals)
jobs.cron('@each5Minute', withLock('publishBids', publishBids))
jobs.cron('@each10Second', pingSnapshot)
jobs.cron('@daily', updateGovernanceBudgets)
jobs.cron('@daily', runAirdropJobs)
jobs.cron('@monthly', giveTopVoterBadges)
jobs.cron('@daily', EventsService.deleteOldEvents)
jobs.cron('30 0 * * *', updateGovernanceBudgets) // Runs at 00:30 daily
jobs.cron('0 1 * * *', EventsService.deleteOldEvents) // Runs at 01:00 daily
jobs.cron('30 1 * * *', runQueuedAirdropJobs) // Runs at 01:30 daily
jobs.cron('30 2 * * *', giveAndRevokeLandOwnerBadges) // Runs at 02:30 daily
jobs.cron('30 3 1 * *', giveTopVoterBadges) // Runs at 03:30 on the first day of the month

const file = readFileSync('static/api.yaml', 'utf8')
const swaggerDocument = YAML.parse(file)
Expand Down

0 comments on commit d76c1cb

Please sign in to comment.