From 50335dc519f961b7178fc985c337e6db9f3168a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 1 Jul 2020 11:48:58 +0200 Subject: [PATCH] Add WORKER_STATUS_FD to WorkerCLICommand --- .../system/cli/command/WorkerCLICommand.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php b/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php index 869d9f15d9..d22226c738 100644 --- a/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php +++ b/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php @@ -16,7 +16,7 @@ use Zend\ProgressBar\ProgressBar; * Executes cronjobs. * * @author Tim Duesterhus - * @copyright 2001-2019 WoltLab GmbH + * @copyright 2001-2020 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\Cli\Command */ @@ -114,6 +114,10 @@ class WorkerCLICommand implements IArgumentedCLICommand { 'width' => CLIWCF::getTerminal()->getWidth() ])); $progress = 0; + $output = null; + if (!empty($_ENV['WORKER_STATUS_FD'])) { + $output = new File("php://fd/".$_ENV['WORKER_STATUS_FD'], "w"); + } for ($i = 0; $progress < 100; $i++) { $worker->setLoopCount($i); $worker->validate(); @@ -125,6 +129,13 @@ class WorkerCLICommand implements IArgumentedCLICommand { // update progress $progress = $worker->getProgress(); $progressbar->update($progress); + if ($output) { + $output->write("$i,$progress\n"); + } + } + if ($output) { + $output->write("done,$progress"); + $output->close(); } $progressbar->update($progress); -- 2.20.1