示例#1
0
 public function execute()
 {
     global $wgCommandLineMode;
     if ($this->hasOption('procs')) {
         $procs = intval($this->getOption('procs'));
         if ($procs < 1 || $procs > 1000) {
             $this->error("Invalid argument to --procs", true);
         } elseif ($procs != 1) {
             $fc = new ForkController($procs);
             if ($fc->start() != 'child') {
                 exit(0);
             }
         }
     }
     $outputJSON = $this->getOption('result') === 'json';
     // Enable DBO_TRX for atomicity; JobRunner manages transactions
     // and works well in web server mode already (@TODO: this is a hack)
     $wgCommandLineMode = false;
     $runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
     if (!$outputJSON) {
         $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 ($outputJSON) {
         $this->output(FormatJson::encode($response, true));
     }
     $wgCommandLineMode = true;
 }
示例#2
0
 public function execute()
 {
     if (wfReadOnly()) {
         $this->error("Unable to run jobs; the wiki is in read-only mode.", 1);
         // die
     }
     if ($this->hasOption('procs')) {
         $procs = intval($this->getOption('procs'));
         if ($procs < 1 || $procs > 1000) {
             $this->error("Invalid argument to --procs", true);
         } elseif ($procs != 1) {
             $fc = new ForkController($procs);
             if ($fc->start() != 'child') {
                 exit(0);
             }
         }
     }
     $json = $this->getOption('result') === 'json';
     $runner = new JobRunner();
     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));
     }
 }
示例#3
0
 public function execute()
 {
     global $wgCommandLineMode;
     if ($this->hasOption('procs')) {
         $procs = intval($this->getOption('procs'));
         if ($procs < 1 || $procs > 1000) {
             $this->error("Invalid argument to --procs", true);
         } elseif ($procs != 1) {
             $fc = new ForkController($procs);
             if ($fc->start() != 'child') {
                 exit(0);
             }
         }
     }
     $outputJSON = $this->getOption('result') === 'json';
     $wait = $this->hasOption('wait');
     // Enable DBO_TRX for atomicity; JobRunner manages transactions
     // and works well in web server mode already (@TODO: this is a hack)
     $wgCommandLineMode = false;
     $runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
     if (!$outputJSON) {
         $runner->setDebugHandler([$this, 'debugInternal']);
     }
     $type = $this->getOption('type', false);
     $maxJobs = $this->getOption('maxjobs', false);
     $maxTime = $this->getOption('maxtime', false);
     $throttle = !$this->hasOption('nothrottle');
     while (true) {
         $response = $runner->run(['type' => $type, 'maxJobs' => $maxJobs, 'maxTime' => $maxTime, 'throttle' => $throttle]);
         if ($outputJSON) {
             $this->output(FormatJson::encode($response, true));
         }
         if (!$wait || $response['reached'] === 'time-limit' || $response['reached'] === 'job-limit' || $response['reached'] === 'memory-limit') {
             break;
         }
         if ($maxJobs !== false) {
             $maxJobs -= count($response['jobs']);
         }
         sleep(1);
     }
     $wgCommandLineMode = true;
 }
示例#4
0
 public function execute()
 {
     if ($this->hasOption('procs')) {
         $procs = intval($this->getOption('procs'));
         if ($procs < 1 || $procs > 1000) {
             $this->error("Invalid argument to --procs", true);
         } elseif ($procs != 1) {
             $fc = new ForkController($procs);
             if ($fc->start() != 'child') {
                 exit(0);
             }
         }
     }
     $outputJSON = $this->getOption('result') === 'json';
     $wait = $this->hasOption('wait');
     $runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
     if (!$outputJSON) {
         $runner->setDebugHandler([$this, 'debugInternal']);
     }
     $type = $this->getOption('type', false);
     $maxJobs = $this->getOption('maxjobs', false);
     $maxTime = $this->getOption('maxtime', false);
     $throttle = !$this->hasOption('nothrottle');
     while (true) {
         $response = $runner->run(['type' => $type, 'maxJobs' => $maxJobs, 'maxTime' => $maxTime, 'throttle' => $throttle]);
         if ($outputJSON) {
             $this->output(FormatJson::encode($response, true));
         }
         if (!$wait || $response['reached'] === 'time-limit' || $response['reached'] === 'job-limit' || $response['reached'] === 'memory-limit') {
             break;
         }
         if ($maxJobs !== false) {
             $maxJobs -= count($response['jobs']);
         }
         sleep(1);
     }
 }