Skip to content

Commit

Permalink
Merge pull request #3904 from magento-thunder/MAGETWO-95675
Browse files Browse the repository at this point in the history
Fixed issues:
 - MAGETWO-95675: Error during setup:static-content:deploy: Error while waiting for package deployed
  • Loading branch information
arhiopterecs authored Mar 22, 2019
2 parents 06269b7 + aa71030 commit 7270d7e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 14 deletions.
14 changes: 14 additions & 0 deletions app/code/Magento/Deploy/Console/DeployStaticOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Magento\Deploy\Console;

use Magento\Deploy\Process\Queue;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

Expand Down Expand Up @@ -57,6 +58,11 @@ class DeployStaticOptions
*/
const JOBS_AMOUNT = 'jobs';

/**
* Key for max execution time option
*/
const MAX_EXECUTION_TIME = 'max-execution-time';

/**
* Force run of static deploy
*/
Expand Down Expand Up @@ -150,6 +156,7 @@ public function getOptionsList()
* Basic options
*
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
private function getBasicOptions()
{
Expand Down Expand Up @@ -216,6 +223,13 @@ private function getBasicOptions()
'Enable parallel processing using the specified number of jobs.',
self::DEFAULT_JOBS_AMOUNT
),
new InputOption(
self::MAX_EXECUTION_TIME,
null,
InputOption::VALUE_OPTIONAL,
'The maximum expected execution time of deployment static process (in seconds).',
Queue::DEFAULT_MAX_EXEC_TIME
),
new InputOption(
self::SYMLINK_LOCALE,
null,
Expand Down
34 changes: 20 additions & 14 deletions app/code/Magento/Deploy/Service/DeployStaticContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,26 @@ public function deploy(array $options)
return;
}

$queue = $this->queueFactory->create(
[
'logger' => $this->logger,
'options' => $options,
'maxProcesses' => $this->getProcessesAmount($options),
'deployPackageService' => $this->objectManager->create(
\Magento\Deploy\Service\DeployPackage::class,
[
'logger' => $this->logger
]
)
]
);
$queueOptions = [
'logger' => $this->logger,
'options' => $options,
'maxProcesses' => $this->getProcessesAmount($options),
'deployPackageService' => $this->objectManager->create(
\Magento\Deploy\Service\DeployPackage::class,
[
'logger' => $this->logger
]
)
];

if (isset($options[Options::MAX_EXECUTION_TIME])) {
$queueOptions['maxExecTime'] = (int)$options[Options::MAX_EXECUTION_TIME];
}

$deployStrategy = $this->deployStrategyFactory->create(
$options[Options::STRATEGY],
[
'queue' => $queue
'queue' => $this->queueFactory->create($queueOptions)
]
);

Expand Down Expand Up @@ -133,6 +135,8 @@ public function deploy(array $options)
}

/**
* Returns amount of parallel processes, returns zero if option wasn't set.
*
* @param array $options
* @return int
*/
Expand All @@ -142,6 +146,8 @@ private function getProcessesAmount(array $options)
}

/**
* Checks if need to refresh only version.
*
* @param array $options
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Deploy\Test\Unit\Service;

use Magento\Deploy\Console\DeployStaticOptions;
use Magento\Deploy\Package\Package;
use Magento\Deploy\Process\Queue;
use Magento\Deploy\Service\Bundle;
Expand Down Expand Up @@ -221,4 +222,35 @@ public function deployDataProvider()
]
];
}

public function testMaxExecutionTimeOptionPassed()
{
$options = [
DeployStaticOptions::MAX_EXECUTION_TIME => 100,
DeployStaticOptions::REFRESH_CONTENT_VERSION_ONLY => false,
DeployStaticOptions::JOBS_AMOUNT => 3,
DeployStaticOptions::STRATEGY => 'compact',
DeployStaticOptions::NO_JAVASCRIPT => true,
DeployStaticOptions::NO_HTML_MINIFY => true,
];

$queueMock = $this->createMock(Queue::class);
$strategyMock = $this->createMock(CompactDeploy::class);
$this->queueFactory->expects($this->once())
->method('create')
->with([
'logger' => $this->logger,
'maxExecTime' => 100,
'maxProcesses' => 3,
'options' => $options,
'deployPackageService' => null
])
->willReturn($queueMock);
$this->deployStrategyFactory->expects($this->once())
->method('create')
->with('compact', ['queue' => $queueMock])
->willReturn($strategyMock);

$this->service->deploy($options);
}
}

0 comments on commit 7270d7e

Please sign in to comment.