MCPcopy Create free account
hub / github.com/DialmasterOrg/Youtarr / startNextJob

Method startNextJob

server/modules/jobModule.js:405–429  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

403 }
404
405 async startNextJob() {
406 logger.info('Looking for next job to start');
407 const jobs = this.getAllJobs();
408 for (let id in jobs) {
409 if (jobs[id].status === 'Pending') {
410 jobs[id].id = id;
411 if (jobs[id].action) {
412 jobs[id].action(jobs[id], true); // Invoke the function
413 } else {
414 // Job is missing its action function (likely loaded from DB after restart)
415 logger.warn({ jobId: id, jobType: jobs[id].jobType },
416 'Cannot start pending job - missing action function, marking as Terminated');
417
418 await this.updateJob(id, {
419 status: 'Terminated',
420 output: 'Job could not be started after server restart',
421 });
422
423 // Try to start the next pending job
424 this.startNextJob();
425 }
426 break;
427 }
428 }
429 }
430
431 async addOrUpdateJob(jobData, isNextJob = false) {
432 let jobId;

Callers 6

saveJobsAndStartNextMethod · 0.95
jobModule.test.jsFile · 0.80
finalizeDownloadJobFunction · 0.80
doDownloadMethod · 0.80
runCompletionSideEffectsFunction · 0.80

Calls 2

getAllJobsMethod · 0.95
updateJobMethod · 0.95

Tested by

no test coverage detected