]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - maintenance/runJobs.php
MediaWiki 1.15.0
[autoinstallsdev/mediawiki.git] / maintenance / runJobs.php
index cee9cb1e02e81a9ced368f7ad8163348d55b1dcc..1340a85770ef11176a6af110148fb52c93d763e4 100644 (file)
  * @ingroup Maintenance
  */
 
-$optionsWithArgs = array( 'maxjobs', 'type' );
+$optionsWithArgs = array( 'maxjobs', 'type', 'procs' );
 $wgUseNormalUser = true;
 require_once( 'commandLine.inc' );
-require_once( "$IP/includes/JobQueue.php" );
-require_once( "$IP/includes/FakeTitle.php" );
+
+if ( isset( $options['procs'] ) ) {
+       $procs = intval( $options['procs'] );
+       if ( $procs < 1 || $procs > 1000 ) {
+               echo "Invalid argument to --procs\n";
+               exit( 1 );
+       }
+       $fc = new ForkController( $procs );
+       if ( $fc->start( $procs ) != 'child' ) {
+               exit( 0 );
+       }
+}
 
 if ( isset( $options['maxjobs'] ) ) {
        $maxJobs = $options['maxjobs'];
@@ -45,10 +55,15 @@ while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) {
                        break;
 
                wfWaitForSlaves( 5 );
-               print wfTimestamp( TS_DB ) . "  " . $job->id . "  " . $job->toString() . "\n";
+               $t = microtime( true );
                $offset=$job->id;
-               if ( !$job->run() ) {
-                       print wfTimestamp( TS_DB ) . "  Error: {$job->error}\n";
+               $status = $job->run();
+               $t = microtime( true ) - $t;
+               $timeMs = intval( $t * 1000 );
+               if ( !$status ) {
+                       runJobsLog( $job->toString() . " t=$timeMs error={$job->error}" );
+               } else {
+                       runJobsLog( $job->toString() . " t=$timeMs good" );
                }
                if ( $maxJobs && ++$n > $maxJobs ) {
                        break 2;
@@ -56,3 +71,10 @@ while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) {
        }
 }
 
+
+function runJobsLog( $msg ) {
+       print wfTimestamp( TS_DB ) . " $msg\n";
+       wfDebugLog( 'runJobs', $msg );
+}
+
+