Skip to content

Commit c4d88d7

Browse files
ENGCOM-6031: Static Content Deploy - Fix timing in multi-job mode #24901
2 parents c67fa3e + f902aab commit c4d88d7

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

app/code/Magento/Deploy/Process/Queue.php

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,32 @@ public function getPackages()
161161
public function process()
162162
{
163163
$returnStatus = 0;
164+
$logDelay = 10;
164165
$this->start = $this->lastJobStarted = time();
165166
$packages = $this->packages;
166167
while (count($packages) && $this->checkTimeout()) {
167168
foreach ($packages as $name => $packageJob) {
168169
// Unsets each member of $packages array (passed by reference) as each is executed
169170
$this->assertAndExecute($name, $packages, $packageJob);
170171
}
171-
$this->logger->info('.');
172-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
173-
sleep(3);
174-
foreach ($this->inProgress as $name => $package) {
175-
if ($this->isDeployed($package)) {
176-
unset($this->inProgress[$name]);
172+
173+
// refresh current status in console once in 10 iterations (once in 5 sec)
174+
if ($logDelay >= 10) {
175+
$this->logger->info('.');
176+
$logDelay = 0;
177+
} else {
178+
$logDelay++;
179+
}
180+
181+
if ($this->isCanBeParalleled()) {
182+
// in parallel mode sleep before trying to check status and run new jobs
183+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
184+
usleep(500000); // 0.5 sec (less sleep == less time waste)
185+
186+
foreach ($this->inProgress as $name => $package) {
187+
if ($this->isDeployed($package)) {
188+
unset($this->inProgress[$name]);
189+
}
177190
}
178191
}
179192
}
@@ -243,15 +256,25 @@ private function executePackage(Package $package, string $name, array &$packages
243256
*/
244257
private function awaitForAllProcesses()
245258
{
259+
$logDelay = 10;
246260
while ($this->inProgress && $this->checkTimeout()) {
247261
foreach ($this->inProgress as $name => $package) {
248262
if ($this->isDeployed($package)) {
249263
unset($this->inProgress[$name]);
250264
}
251265
}
252-
$this->logger->info('.');
266+
267+
// refresh current status in console once in 10 iterations (once in 5 sec)
268+
if ($logDelay >= 10) {
269+
$this->logger->info('.');
270+
$logDelay = 0;
271+
} else {
272+
$logDelay++;
273+
}
274+
275+
// sleep before checking parallel jobs status
253276
// phpcs:ignore Magento2.Functions.DiscouragedFunction
254-
sleep(5);
277+
usleep(500000); // 0.5 sec (less sleep == less time waste)
255278
}
256279
if ($this->isCanBeParalleled()) {
257280
// close connections only if ran with forks

app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function testProcess()
112112
$package->expects($this->any())->method('getArea')->willReturn('area');
113113
$package->expects($this->any())->method('getPath')->willReturn('path');
114114
$package->expects($this->any())->method('getFiles')->willReturn([]);
115+
$this->logger->expects($this->exactly(2))->method('info')->willReturnSelf();
115116

116117
$this->appState->expects($this->once())->method('emulateAreaCode');
117118

0 commit comments

Comments
 (0)