function runCheckJobThreadsLoop() { global $IP, $wgTranscodeBackgroundTimeLimit; // Check if we have $threads number of webTranscode jobs running else sleep $runingJobsCount = 0; foreach ($this->getProcessList() as $pid => $proc) { // Check that the process is a "runJobs.php" action with type webVideoTranscode argument if (strpos($proc['args'], 'runJobs.php') !== false && strpos($proc['args'], '--type webVideoTranscode') !== false) { if (TimedMediaHandler::parseTimeString($proc['time']) > $wgTranscodeBackgroundTimeLimit) { // should probably "kill" the process $killSuccess = posix_kill($pid); $this->output("Trying to expire transcode job: " . $pid . " result:" . $killSuccess); } else { // Job is oky add to count: $runingJobsCount++; } } } if ($runingJobsCount < $this->threads) { // Add one process: $parameters = array(); if ($this->wiki) { $parameters[] = '--wiki'; $parameters[] = $this->wiki; } $parameters[] = '--type'; $parameters[] = 'webVideoTranscode'; $parameters[] = '--maxjobs'; $parameters[] = '1'; $parameters[] = '--maxtime'; $parameters[] = $wgTranscodeBackgroundTimeLimit; $cmd = wfShellMaintenanceCmd("{$IP}/maintenance/runJobs.php", $parameters); $status = $this->runBackgroundProc($cmd); $this->output("{$runingJobsCount} existing job runners, Check for new transcode jobs: "); } else { // Just output a "tick" $this->output("{$runingJobsCount} transcode jobs active:\n"); } }
/** * @dataProvider provideWfShellMaintenanceCmdList * @covers ::wfShellMaintenanceCmd */ public function testWfShellMaintenanceCmd($script, $parameters, $options, $expected, $description) { if (wfIsWindows()) { // Approximation that's good enough for our purposes just now $expected = str_replace("'", '"', $expected); } $actual = wfShellMaintenanceCmd($script, $parameters, $options); $this->assertEquals($expected, $actual, $description); }