X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrunJobs.php;h=80a227810e66722fdff898d1195f5ef6672317b4;hb=1162a32ef22973ba3c92b7b91c146deef217be10;hp=af7c906cc305c707b28b6f11ac0c58fc1c06ea00;hpb=9846b1c1e9f473b79f581028dce06311530ef545;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index af7c906cc3..80a227810e 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -25,7 +25,7 @@ * @ingroup Maintenance */ -require_once( dirname( __FILE__ ) . '/Maintenance.php' ); +require_once( __DIR__ . '/Maintenance.php' ); /** * Maintenance script that runs pending jobs. @@ -52,6 +52,7 @@ class RunJobs extends Maintenance { public function execute() { global $wgTitle; + if ( $this->hasOption( 'procs' ) ) { $procs = intval( $this->getOption( 'procs' ) ); if ( $procs < 1 || $procs > 1000 ) { @@ -70,26 +71,17 @@ class RunJobs extends Maintenance { $dbw = wfGetDB( DB_MASTER ); $n = 0; - if ( $type === false ) { - $conds = Job::defaultQueueConditions( ); - } else { - $conds = array( 'job_cmd' => $type ); - } - - while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) { - $offset = 0; - for ( ; ; ) { - $job = !$type ? Job::pop( $offset ) : Job::pop_type( $type ); - - if ( !$job ) { - break; - } - - wfWaitForSlaves(); + $group = JobQueueGroup::singleton(); + do { + $job = ( $type === false ) + ? $group->pop() // job from any queue + : $group->get( $type )->pop(); // job from a single queue + if ( $job ) { // found a job + // Perform the job (logging success/failure and runtime)... $t = microtime( true ); - $offset = $job->id; $this->runJobsLog( $job->toString() . " STARTING" ); $status = $job->run(); + $group->ack( $job ); // done $t = microtime( true ) - $t; $timeMs = intval( $t * 1000 ); if ( !$status ) { @@ -97,15 +89,17 @@ class RunJobs extends Maintenance { } else { $this->runJobsLog( $job->toString() . " t=$timeMs good" ); } - - if ( $maxJobs && ++$n > $maxJobs ) { + // Break out if we hit the job count or wall time limits... + if ( $maxJobs && ++$n >= $maxJobs ) { break 2; } - if ( $maxTime && time() - $startTime > $maxTime ) { + if ( $maxTime && ( time() - $startTime ) > $maxTime ) { break 2; } + // Don't let any slaves/backups fall behind... + $group->get( $type )->waitForBackups(); } - } + } while ( $job ); // stop when there are no jobs } /**