Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 7270d7e

Browse files
authored
Merge pull request #3904 from magento-thunder/MAGETWO-95675
Fixed issues: - MAGETWO-95675: Error during setup:static-content:deploy: Error while waiting for package deployed
2 parents 06269b7 + aa71030 commit 7270d7e

File tree

3 files changed

+66
-14
lines changed

3 files changed

+66
-14
lines changed

app/code/Magento/Deploy/Console/DeployStaticOptions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Deploy\Console;
88

9+
use Magento\Deploy\Process\Queue;
910
use Symfony\Component\Console\Input\InputOption;
1011
use Symfony\Component\Console\Input\InputArgument;
1112

@@ -57,6 +58,11 @@ class DeployStaticOptions
5758
*/
5859
const JOBS_AMOUNT = 'jobs';
5960

61+
/**
62+
* Key for max execution time option
63+
*/
64+
const MAX_EXECUTION_TIME = 'max-execution-time';
65+
6066
/**
6167
* Force run of static deploy
6268
*/
@@ -150,6 +156,7 @@ public function getOptionsList()
150156
* Basic options
151157
*
152158
* @return array
159+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
153160
*/
154161
private function getBasicOptions()
155162
{
@@ -216,6 +223,13 @@ private function getBasicOptions()
216223
'Enable parallel processing using the specified number of jobs.',
217224
self::DEFAULT_JOBS_AMOUNT
218225
),
226+
new InputOption(
227+
self::MAX_EXECUTION_TIME,
228+
null,
229+
InputOption::VALUE_OPTIONAL,
230+
'The maximum expected execution time of deployment static process (in seconds).',
231+
Queue::DEFAULT_MAX_EXEC_TIME
232+
),
219233
new InputOption(
220234
self::SYMLINK_LOCALE,
221235
null,

app/code/Magento/Deploy/Service/DeployStaticContent.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,26 @@ public function deploy(array $options)
8585
return;
8686
}
8787

88-
$queue = $this->queueFactory->create(
89-
[
90-
'logger' => $this->logger,
91-
'options' => $options,
92-
'maxProcesses' => $this->getProcessesAmount($options),
93-
'deployPackageService' => $this->objectManager->create(
94-
\Magento\Deploy\Service\DeployPackage::class,
95-
[
96-
'logger' => $this->logger
97-
]
98-
)
99-
]
100-
);
88+
$queueOptions = [
89+
'logger' => $this->logger,
90+
'options' => $options,
91+
'maxProcesses' => $this->getProcessesAmount($options),
92+
'deployPackageService' => $this->objectManager->create(
93+
\Magento\Deploy\Service\DeployPackage::class,
94+
[
95+
'logger' => $this->logger
96+
]
97+
)
98+
];
99+
100+
if (isset($options[Options::MAX_EXECUTION_TIME])) {
101+
$queueOptions['maxExecTime'] = (int)$options[Options::MAX_EXECUTION_TIME];
102+
}
101103

102104
$deployStrategy = $this->deployStrategyFactory->create(
103105
$options[Options::STRATEGY],
104106
[
105-
'queue' => $queue
107+
'queue' => $this->queueFactory->create($queueOptions)
106108
]
107109
);
108110

@@ -133,6 +135,8 @@ public function deploy(array $options)
133135
}
134136

135137
/**
138+
* Returns amount of parallel processes, returns zero if option wasn't set.
139+
*
136140
* @param array $options
137141
* @return int
138142
*/
@@ -142,6 +146,8 @@ private function getProcessesAmount(array $options)
142146
}
143147

144148
/**
149+
* Checks if need to refresh only version.
150+
*
145151
* @param array $options
146152
* @return bool
147153
*/

app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Deploy\Test\Unit\Service;
77

8+
use Magento\Deploy\Console\DeployStaticOptions;
89
use Magento\Deploy\Package\Package;
910
use Magento\Deploy\Process\Queue;
1011
use Magento\Deploy\Service\Bundle;
@@ -221,4 +222,35 @@ public function deployDataProvider()
221222
]
222223
];
223224
}
225+
226+
public function testMaxExecutionTimeOptionPassed()
227+
{
228+
$options = [
229+
DeployStaticOptions::MAX_EXECUTION_TIME => 100,
230+
DeployStaticOptions::REFRESH_CONTENT_VERSION_ONLY => false,
231+
DeployStaticOptions::JOBS_AMOUNT => 3,
232+
DeployStaticOptions::STRATEGY => 'compact',
233+
DeployStaticOptions::NO_JAVASCRIPT => true,
234+
DeployStaticOptions::NO_HTML_MINIFY => true,
235+
];
236+
237+
$queueMock = $this->createMock(Queue::class);
238+
$strategyMock = $this->createMock(CompactDeploy::class);
239+
$this->queueFactory->expects($this->once())
240+
->method('create')
241+
->with([
242+
'logger' => $this->logger,
243+
'maxExecTime' => 100,
244+
'maxProcesses' => 3,
245+
'options' => $options,
246+
'deployPackageService' => null
247+
])
248+
->willReturn($queueMock);
249+
$this->deployStrategyFactory->expects($this->once())
250+
->method('create')
251+
->with('compact', ['queue' => $queueMock])
252+
->willReturn($strategyMock);
253+
254+
$this->service->deploy($options);
255+
}
224256
}

0 commit comments

Comments
 (0)