Skip to content

Commit

Permalink
Chunck parallel processes better
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Mar 7, 2024
1 parent a2a3e7b commit 6362e51
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Blt/Plugin/Commands/SwsCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,16 @@ public function postCodeDeployUpdate($target_env, $deployed_tag, $options = ['no
$sites = $this->getConfigValue('multisites');
$parallel_executions = (int) getenv('UPDATE_PARALLEL_PROCESSES') ?: 10;

$site_chunks = array_chunk($sites, ceil(count($sites) / $parallel_executions));
$i = 0;
while ($sites) {
$site = array_splice($sites, 0, 1);
$site_chunks[$i][] = reset($site);
$i++;
if ($i >= $parallel_executions) {
$i = 0;
}
}

$commands = [];
foreach ($site_chunks as $sites) {
$command = $this->blt()
Expand All @@ -398,6 +407,7 @@ public function postCodeDeployUpdate($target_env, $deployed_tag, $options = ['no
}
$commands[] = $command->getCommand();
}

file_put_contents(sys_get_temp_dir() . '/success-report.txt', '');
file_put_contents(sys_get_temp_dir() . '/failed-report.txt', '');

Expand Down

0 comments on commit 6362e51

Please sign in to comment.