MDL-80309 tasks: Clean up mtrace logs
This commit is contained in:
@@ -1392,12 +1392,40 @@ class manager {
|
||||
$command = "{$phpbinary} {$scriptpath} {$taskarg}";
|
||||
|
||||
// Execute it.
|
||||
passthru($command);
|
||||
self::passthru_via_mtrace($command);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This behaves similar to passthru but filters every line via
|
||||
* the mtrace function so it can be post processed.
|
||||
*
|
||||
* @param string $command to run
|
||||
* @return void
|
||||
*/
|
||||
public static function passthru_via_mtrace(string $command) {
|
||||
$descriptorspec = [
|
||||
0 => ['pipe', 'r'], // STDIN.
|
||||
1 => ['pipe', 'w'], // STDOUT.
|
||||
2 => ['pipe', 'w'], // STDERR.
|
||||
];
|
||||
flush();
|
||||
$process = proc_open($command, $descriptorspec, $pipes, realpath('./'), []);
|
||||
if (is_resource($process)) {
|
||||
while ($s = fgets($pipes[1])) {
|
||||
mtrace($s, '');
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
fclose($pipes[0]);
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
proc_close($process);
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given scheduled task record, this method will check to see if any overrides have
|
||||
* been applied in config and return a copy of the record with any overridden values.
|
||||
|
||||
Reference in New Issue
Block a user