X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FshowJobs.php;h=e7ddfa80891f9e40d03b8869101492cb5dd8ff08;hb=e593d18a886a9a9286753b41e4941fcb456a616a;hp=1dceb7907f0a63d5535525e6bda805266a3fe8fc;hpb=410d1617dbb245d351a85eac9391c0b73960e691;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/showJobs.php b/maintenance/showJobs.php index 1dceb7907f..e7ddfa8089 100644 --- a/maintenance/showJobs.php +++ b/maintenance/showJobs.php @@ -39,21 +39,29 @@ class ShowJobs extends Maintenance { $this->mDescription = "Show number of jobs waiting in master database"; $this->addOption( 'group', 'Show number of jobs per job type' ); } + public function execute() { - $dbw = wfGetDB( DB_MASTER ); + $group = JobQueueGroup::singleton(); if ( $this->hasOption( 'group' ) ) { - $res = $dbw->select( - 'job', - array( 'job_cmd', 'count(*) as count' ), - array(), - __METHOD__, - array( 'GROUP BY' => 'job_cmd' ) - ); - foreach ( $res as $row ) { - $this->output( $row->job_cmd . ': ' . $row->count . "\n" ); + foreach ( $group->getQueueTypes() as $type ) { + $queue = $group->get( $type ); + $pending = $queue->getSize(); + $claimed = $queue->getAcquiredCount(); + $abandoned = $queue->getAbandonedCount(); + $active = ( $claimed - $abandoned ); + if ( ( $pending + $claimed ) > 0 ) { + $this->output( + "{$type}: $pending queued; " . + "$claimed claimed ($active active, $abandoned abandoned)\n" + ); + } } } else { - $this->output( $dbw->selectField( 'job', 'count(*)', '', __METHOD__ ) . "\n" ); + $count = 0; + foreach ( $group->getQueueTypes() as $type ) { + $count += $group->get( $type )->getSize(); + } + $this->output( "$count\n" ); } } }