27require_once __DIR__ .
'/Maintenance.php';
37 parent::__construct();
38 $this->
addDescription(
'Perform administrative tasks on a job queue' );
39 $this->
addOption(
'type',
'Job type',
true,
true );
40 $this->
addOption(
'action',
'Queue operation ("delete", "repush-abandoned")',
true,
true );
49 $queue = $group->get( $type );
51 if ( $action ===
'delete' ) {
52 $this->
delete( $queue );
53 } elseif ( $action ===
'repush-abandoned' ) {
54 $this->repushAbandoned( $queue );
56 $this->
fatalError(
"Invalid action '$action'." );
60 private function delete(
JobQueue $queue ) {
61 $this->
output(
"Queue has {$queue->getSize()} job(s); deleting...\n" );
63 $this->
output(
"Done; current size is {$queue->getSize()} job(s).\n" );
66 private function repushAbandoned(
JobQueue $queue ) {
68 $key = $cache->makeGlobalKey(
'last-job-repush', $queue->
getDomain(), $queue->
getType() );
71 $lastRepushTime = $cache->get( $key );
72 if ( $lastRepushTime ===
false ) {
76 $this->
output(
"Last re-push time: $lastRepushTime; current time: $now\n" );
95 $cache->set( $key, $now );
97 $this->
output(
"Re-pushed $count job(s) [$skipped skipped].\n" );
103require_once RUN_MAINTENANCE_IF_MAIN;
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Base class for queueing and running background jobs from a storage backend.
waitForBackups()
Wait for any replica DBs or backup servers to catch up.
push( $jobs, $flags=0)
Push one or more jobs into the queue.
delete()
Delete all unclaimed and delayed jobs from the queue.
getAllAbandonedJobs()
Get an iterator to traverse over all abandoned jobs in this queue.
Describe and execute a background job.
Maintenance script that handles managing job queue admin tasks (re-push, delete, ....
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getBatchSize()
Returns batch size.
output( $out, $channel=null)
Throw some output to the user.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
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.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.
if(count( $args)< 1) $job