From 5dc6ff0f3606746303cc8bf62efbff50fbffb839 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 28 Jul 2014 10:30:18 -0700 Subject: [PATCH] Added support for result=json parameter to runJobs.php * This can let the caller get info about what was run, just like the web version Change-Id: I49d7eccee52eb1dc161249fdc0546259ccf1f959 --- maintenance/runJobs.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index 3e6fa52c8c..c7578029b1 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -37,6 +37,7 @@ class RunJobs extends Maintenance { $this->addOption( 'type', 'Type of job to run', false, true ); $this->addOption( 'procs', 'Number of processes to use', false, true ); $this->addOption( 'nothrottle', 'Ignore job throttling configuration', false, false ); + $this->addOption( 'result', 'Set to JSON to print only a JSON response', false, false ); } public function memoryLimit() { @@ -65,14 +66,21 @@ class RunJobs extends Maintenance { } } + $json = ( $this->getOption( 'result' ) === 'json' ); + $runner = new JobRunner(); - $runner->setDebugHandler( array( $this, 'debugInternal' ) ); - $runner->run( array( + if ( !$json ) { + $runner->setDebugHandler( array( $this, 'debugInternal' ) ); + } + $response = $runner->run( array( 'type' => $this->getOption( 'type', false ), 'maxJobs' => $this->getOption( 'maxjobs', false ), 'maxTime' => $this->getOption( 'maxtime', false ), 'throttle' => $this->hasOption( 'nothrottle' ) ? false : true, ) ); + if ( $json ) { + $this->output( FormatJson::encode( $response, true ) ); + } } /** -- 2.20.1