WIKI.logger.debug('All workers are busy. Cannot process more jobs at the moment.')
return
}
awaitWIKI.db.knex.transaction(asynctrx=>{
constjobs=awaittrx('jobs')
.where('id',WIKI.db.knex.raw('(SELECT id FROM jobs WHERE ("waitUntil" IS NULL OR "waitUntil" <= NOW()) ORDER BY id FOR UPDATE SKIP LOCKED LIMIT 1)'))
.whereIn('id',WIKI.db.knex.raw(`(SELECT id FROM jobs WHERE ("waitUntil" IS NULL OR "waitUntil" <= NOW()) ORDER BY id FOR UPDATE SKIP LOCKED LIMIT ${availableWorkers})`))
.returning('*')
.del()
if(jobs&&jobs.length===1){
constjob=jobs[0]
WIKI.logger.info(`Processing new job ${job.id}: ${job.task}...`)