21 require_once __DIR__ .
'/Maintenance.php';
37 'unclaimed' =>
'getAllQueuedJobs',
38 'delayed' =>
'getAllDelayedJobs',
39 'claimed' =>
'getAllAcquiredJobs',
40 'abandoned' =>
'getAllAbandonedJobs',
44 parent::__construct();
45 $this->
addDescription(
'Show number of jobs waiting in primary database' );
46 $this->
addOption(
'group',
'Show number of jobs per job type' );
47 $this->
addOption(
'list',
'Show a list of all jobs instead of counts' );
48 $this->
addOption(
'type',
'Only show/count jobs of a given type',
false,
true );
49 $this->
addOption(
'status',
'Filter list by state (unclaimed,delayed,claimed,abandoned)' );
50 $this->
addOption(
'limit',
'Limit of jobs listed' );
54 $typeFilter = $this->
getOption(
'type',
'' );
55 $stateFilter = $this->
getOption(
'status',
'' );
56 $stateLimit = (float)$this->
getOption(
'limit', INF );
60 $filteredTypes = $typeFilter
62 : $group->getQueueTypes();
63 $filteredStates = $stateFilter
64 ? array_intersect_key( self::$stateMethods, [ $stateFilter => 1 ] )
69 foreach ( $filteredTypes as $type ) {
70 $queue = $group->get( $type );
71 foreach ( $filteredStates as $state => $method ) {
72 foreach ( $queue->$method() as
$job ) {
74 $this->
output( $job->toString() .
" status=$state\n" );
75 if ( ++$count >= $stateLimit ) {
81 } elseif ( $this->
hasOption(
'group' ) ) {
82 foreach ( $filteredTypes as $type ) {
83 $queue = $group->get( $type );
84 $delayed = $queue->getDelayedCount();
85 $pending = $queue->getSize();
86 $claimed = $queue->getAcquiredCount();
87 $abandoned = $queue->getAbandonedCount();
88 $active = max( 0, $claimed - $abandoned );
89 if ( ( $pending + $claimed + $delayed + $abandoned ) > 0 ) {
91 "{$type}: $pending queued; " .
92 "$claimed claimed ($active active, $abandoned abandoned); " .
99 foreach ( $filteredTypes as $type ) {
100 $count += $group->get( $type )->getSize();
102 $this->
output(
"$count\n" );
108 require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option was set.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
Report number of jobs currently waiting in primary database.
execute()
Do the actual work.
__construct()
Default constructor.
if(count( $args)< 1) $job