Skip to content

Commit ba974c4

Browse files
committed
MAGETWO-50673: Static asset deployment is crazy slow with multiple locales
- MAGETWO-54819: Make deploy configurable
1 parent ba53c7a commit ba974c4

File tree

3 files changed

+163
-196
lines changed

3 files changed

+163
-196
lines changed

app/code/Magento/Deploy/Console/Command/DeployStaticContentCommand.php

Lines changed: 31 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Deploy\Model\Process;
2121
use Magento\Framework\Exception\LocalizedException;
2222
use Magento\Framework\App\State;
23+
use Magento\Deploy\Console\Command\DeployStaticOptionsInterface as Options;
2324

2425
/**
2526
* Deploy static content command
@@ -32,100 +33,15 @@ class DeployStaticContentCommand extends Command
3233
*/
3334
const DEFAULT_LANGUAGE_VALUE = 'en_US';
3435

35-
/**
36-
* Key for dry-run option
37-
*/
38-
const DRY_RUN_OPTION = 'dry-run';
39-
4036
/**
4137
* Key for languages parameter
4238
*/
4339
const LANGUAGES_ARGUMENT = 'languages';
4440

45-
/**
46-
* Key for languages parameter
47-
*/
48-
const LANGUAGE_OPTION = 'language';
49-
50-
/**
51-
* Key for exclude languages parameter
52-
*/
53-
const EXCLUDE_LANGUAGE_OPTION = 'exclude-language';
54-
55-
/**
56-
* Key for javascript option
57-
*/
58-
const JAVASCRIPT_OPTION = 'no-javascript';
59-
60-
/**
61-
* Key for css option
62-
*/
63-
const CSS_OPTION = 'no-css';
64-
65-
/**
66-
* Key for less option
67-
*/
68-
const LESS_OPTION = 'no-less';
69-
70-
/**
71-
* Key for images option
72-
*/
73-
const IMAGES_OPTION = 'no-images';
74-
75-
/**
76-
* Key for fonts option
77-
*/
78-
const FONTS_OPTION = 'no-fonts';
79-
80-
/**
81-
* Key for misc option
82-
*/
83-
const MISC_OPTION = 'no-misc';
84-
85-
/**
86-
* Key for html option
87-
*/
88-
const HTML_OPTION = 'no-html';
89-
90-
/**
91-
* Key for html option
92-
*/
93-
const HTML_MINIFY_OPTION = 'no-html-minify';
94-
95-
/**
96-
* Key for theme option
97-
*/
98-
const THEME_OPTION = 'theme';
99-
100-
/**
101-
* Key for exclude theme option
102-
*/
103-
const EXCLUDE_THEME_OPTION = 'exclude-theme';
104-
105-
/**
106-
* Key for area option
107-
*/
108-
const AREA_OPTION = 'area';
109-
110-
/**
111-
* Key for exclude area option
112-
*/
113-
const EXCLUDE_AREA_OPTION = 'exclude-area';
114-
115-
/**
116-
* Jey for jobs option
117-
*/
118-
const JOBS_AMOUNT = 'jobs';
119-
12041
/**
12142
* Default jobs amount
12243
*/
123-
const DEFAULT_JOBS_AMOUNT = 3;
124-
125-
/**
126-
* Force run of static deploy
127-
*/
128-
const FORCE_RUN_OPTION = 'force';
44+
const DEFAULT_JOBS_AMOUNT = 4;
12945

13046
/** @var InputInterface */
13147
private $input;
@@ -182,109 +98,109 @@ protected function configure()
18298
->setDescription('Deploys static view files')
18399
->setDefinition([
184100
new InputOption(
185-
self::DRY_RUN_OPTION,
101+
Options::DRY_RUN_OPTION,
186102
'-d',
187103
InputOption::VALUE_NONE,
188104
'If specified, then no files will be actually deployed.'
189105
),
190106
new InputOption(
191-
self::FORCE_RUN_OPTION,
107+
Options::FORCE_RUN_OPTION,
192108
'-f',
193109
InputOption::VALUE_NONE,
194110
'If specified, then run files will be deployed in any mode.'
195111
),
196112
new InputOption(
197-
self::JAVASCRIPT_OPTION,
113+
Options::JAVASCRIPT_OPTION,
198114
null,
199115
InputOption::VALUE_NONE,
200116
'If specified, no JavaScript will be deployed.'
201117
),
202118
new InputOption(
203-
self::CSS_OPTION,
119+
Options::CSS_OPTION,
204120
null,
205121
InputOption::VALUE_NONE,
206122
'If specified, no CSS will be deployed.'
207123
),
208124
new InputOption(
209-
self::LESS_OPTION,
125+
Options::LESS_OPTION,
210126
null,
211127
InputOption::VALUE_NONE,
212128
'If specified, no LESS will be deployed.'
213129
),
214130
new InputOption(
215-
self::IMAGES_OPTION,
131+
Options::IMAGES_OPTION,
216132
null,
217133
InputOption::VALUE_NONE,
218134
'If specified, no images will be deployed.'
219135
),
220136
new InputOption(
221-
self::FONTS_OPTION,
137+
Options::FONTS_OPTION,
222138
null,
223139
InputOption::VALUE_NONE,
224140
'If specified, no font files will be deployed.'
225141
),
226142
new InputOption(
227-
self::HTML_OPTION,
143+
Options::HTML_OPTION,
228144
null,
229145
InputOption::VALUE_NONE,
230146
'If specified, no html files will be deployed.'
231147
),
232148
new InputOption(
233-
self::MISC_OPTION,
149+
Options::MISC_OPTION,
234150
null,
235151
InputOption::VALUE_NONE,
236152
'If specified, no miscellaneous files will be deployed.'
237153
),
238154
new InputOption(
239-
self::HTML_MINIFY_OPTION,
155+
Options::HTML_MINIFY_OPTION,
240156
null,
241157
InputOption::VALUE_NONE,
242158
'If specified, just html will not be minified and actually deployed.'
243159
),
244160
new InputOption(
245-
self::THEME_OPTION,
161+
Options::THEME_OPTION,
246162
'-t',
247163
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
248164
'If specified, just specific theme(s) will be actually deployed.',
249165
['all']
250166
),
251167
new InputOption(
252-
self::EXCLUDE_THEME_OPTION,
168+
Options::EXCLUDE_THEME_OPTION,
253169
null,
254170
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
255171
'If specified, exclude specific theme(s) from deployment.',
256172
['none']
257173
),
258174
new InputOption(
259-
self::LANGUAGE_OPTION,
175+
Options::LANGUAGE_OPTION,
260176
'-l',
261177
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
262178
'List of languages you want the tool populate files for.',
263179
['all']
264180
),
265181
new InputOption(
266-
self::EXCLUDE_LANGUAGE_OPTION,
182+
Options::EXCLUDE_LANGUAGE_OPTION,
267183
null,
268184
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
269185
'List of langiages you do not want the tool populate files for.',
270186
['none']
271187
),
272188
new InputOption(
273-
self::AREA_OPTION,
189+
Options::AREA_OPTION,
274190
'-a',
275191
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
276192
'List of areas you want the tool populate files for.',
277193
['all']
278194
),
279195
new InputOption(
280-
self::EXCLUDE_AREA_OPTION,
196+
Options::EXCLUDE_AREA_OPTION,
281197
null,
282198
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
283199
'List of areas you do not want the tool populate files for.',
284200
['none']
285201
),
286202
new InputOption(
287-
self::JOBS_AMOUNT,
203+
Options::JOBS_AMOUNT_OPTION,
288204
'-j',
289205
InputOption::VALUE_OPTIONAL,
290206
'Amount of jobs to which script can be paralleled.',
@@ -441,7 +357,9 @@ private function getDeployableEntities($entities, $includedEntities, $excludedEn
441357
*/
442358
protected function execute(InputInterface $input, OutputInterface $output)
443359
{
444-
if (!$input->getOption(self::FORCE_RUN_OPTION) && $this->getAppState()->getMode() !== State::MODE_PRODUCTION) {
360+
if (!$input->getOption(Options::FORCE_RUN_OPTION)
361+
&& $this->getAppState()->getMode() !== State::MODE_PRODUCTION
362+
) {
445363
throw new LocalizedException(
446364
__(
447365
"Deploy static content is applicable only for production mode.\n"
@@ -460,21 +378,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
460378
$output->writeln("Requested areas: " . implode(', ', array_keys($deployableAreaThemeMap)));
461379
$output->writeln("Requested themes: " . implode(', ', $requestedThemes));
462380

463-
$options = $this->input->getOptions();
464381
$deployer = $this->objectManager->create(
465382
\Magento\Deploy\Model\Deployer::class,
466383
[
467384
'filesUtil' => $filesUtil,
468385
'output' => $output,
469-
'isDryRun' => $options[self::DRY_RUN_OPTION],
470-
'skipJavaScript' => $options[self::JAVASCRIPT_OPTION],
471-
'skipCss' => $options[self::CSS_OPTION],
472-
'skipLess' => $options[self::LESS_OPTION],
473-
'skipImages' => $options[self::IMAGES_OPTION],
474-
'skipFonts' => $options[self::FONTS_OPTION],
475-
'skipHtml' => $options[self::HTML_OPTION],
476-
'skipMisc' => $options[self::MISC_OPTION],
477-
'skipHtmlMinify' => $options[self::HTML_MINIFY_OPTION]
386+
'options' => $this->input->getOptions(),
478387
]
479388
);
480389

@@ -514,21 +423,21 @@ private function prepareDeployableEntities($filesUtil)
514423
}
515424
}
516425

517-
$areasInclude = $this->input->getOption(self::AREA_OPTION);
518-
$areasExclude = $this->input->getOption(self::EXCLUDE_AREA_OPTION);
426+
$areasInclude = $this->input->getOption(Options::AREA_OPTION);
427+
$areasExclude = $this->input->getOption(Options::EXCLUDE_AREA_OPTION);
519428
$this->checkAreasInput($magentoAreas, $areasInclude, $areasExclude);
520429
$deployableAreas = $this->getDeployableEntities($magentoAreas, $areasInclude, $areasExclude);
521430

522431
$languagesInclude = $this->input->getArgument(self::LANGUAGES_ARGUMENT)
523-
?: $this->input->getOption(self::LANGUAGE_OPTION);
524-
$languagesExclude = $this->input->getOption(self::EXCLUDE_LANGUAGE_OPTION);
432+
?: $this->input->getOption(Options::LANGUAGE_OPTION);
433+
$languagesExclude = $this->input->getOption(Options::EXCLUDE_LANGUAGE_OPTION);
525434
$this->checkLanguagesInput($languagesInclude, $languagesExclude);
526435
$deployableLanguages = $languagesInclude[0] == 'all'
527436
? $this->getDeployableEntities($magentoLanguages, $languagesInclude, $languagesExclude)
528437
: $languagesInclude;
529438

530-
$themesInclude = $this->input->getOption(self::THEME_OPTION);
531-
$themesExclude = $this->input->getOption(self::EXCLUDE_THEME_OPTION);
439+
$themesInclude = $this->input->getOption(Options::THEME_OPTION);
440+
$themesExclude = $this->input->getOption(Options::EXCLUDE_THEME_OPTION);
532441
$this->checkThemesInput($magentoThemes, $themesInclude, $themesExclude);
533442
$deployableThemes = $this->getDeployableEntities($magentoThemes, $themesInclude, $themesExclude);
534443

@@ -620,10 +529,10 @@ private function isCanBeParalleled()
620529
*/
621530
private function getProcessesAmount()
622531
{
623-
$jobs = (int)$this->input->getOption(self::JOBS_AMOUNT);
532+
$jobs = (int)$this->input->getOption(Options::JOBS_AMOUNT_OPTION);
624533
if ($jobs < 1) {
625534
throw new \InvalidArgumentException(
626-
self::JOBS_AMOUNT . ' argument has invalid value. It must be greater than 0'
535+
Options::JOBS_AMOUNT_OPTION . ' argument has invalid value. It must be greater than 0'
627536
);
628537
}
629538
return $jobs;

0 commit comments

Comments
 (0)