From e9d2a59ecac859a0049803b29c19acf354676afc Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Tue, 28 Jun 2016 10:27:46 +0200 Subject: [PATCH] Chunk authorization requests into groups of 10 --- src/Commands/Issue.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Commands/Issue.php b/src/Commands/Issue.php index 83c260c..033b5e7 100644 --- a/src/Commands/Issue.php +++ b/src/Commands/Issue.php @@ -80,14 +80,22 @@ class Issue implements Command { $this->climate->br(); $acme = $this->acmeFactory->build($server, $keyPair); - $promises = []; + $errors = []; - foreach ($domains as $i => $domain) { - $promises[] = \Amp\resolve($this->solveChallenge($acme, $keyPair, $domain, $docRoots[$i])); + $domainChunks = array_chunk($domains, 10, true); + + foreach ($domainChunks as $domainChunk) { + $promises = []; + + foreach ($domainChunk as $i => $domain) { + $promises[] = \Amp\resolve($this->solveChallenge($acme, $keyPair, $domain, $docRoots[$i])); + } + + list($chunkErrors) = (yield \Amp\any($promises)); + + $errors += $chunkErrors; } - list($errors) = (yield \Amp\any($promises)); - if (!empty($errors)) { foreach ($errors as $error) { $this->climate->error($error->getMessage());