Issue certificates sequential, allow changing the challenge concurrency
This commit is contained in:
@@ -89,6 +89,14 @@ class Auto implements Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($config["challenge-concurrency"]) && !is_numeric($config["challenge-concurrency"])) {
|
||||||
|
$this->climate->error("Config file ({$configPath}) defines an invalid 'challenge-concurrency' value.");
|
||||||
|
yield new CoroutineResult(self::EXIT_CONFIG_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$concurrency = isset($config["challenge-concurrency"]) ? (int) $config["challenge-concurrency"] : null;
|
||||||
|
|
||||||
$command = implode(" ", array_map("escapeshellarg", [
|
$command = implode(" ", array_map("escapeshellarg", [
|
||||||
PHP_BINARY,
|
PHP_BINARY,
|
||||||
$GLOBALS["argv"][0],
|
$GLOBALS["argv"][0],
|
||||||
@@ -113,22 +121,16 @@ class Auto implements Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$certificateChunks = array_chunk($config["certificates"], 10, true);
|
|
||||||
|
|
||||||
$errors = [];
|
$errors = [];
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
foreach ($certificateChunks as $certificateChunk) {
|
foreach ($config["certificates"] as $i => $certificate) {
|
||||||
$promises = [];
|
try {
|
||||||
|
$result = (yield \Amp\resolve($this->checkAndIssue($certificate, $config["server"], $config["storage"], $concurrency)));
|
||||||
foreach ($certificateChunk as $certificate) {
|
$values[$i] = $result;
|
||||||
$promises[] = \Amp\resolve($this->checkAndIssue($certificate, $config["server"], $config["storage"]));
|
} catch (\Exception $e) {
|
||||||
|
$errors[$i] = $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($chunkErrors, $chunkValues) = (yield \Amp\any($promises));
|
|
||||||
|
|
||||||
$errors += $chunkErrors;
|
|
||||||
$values += $chunkValues;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = [
|
$status = [
|
||||||
@@ -171,10 +173,11 @@ class Auto implements Command {
|
|||||||
* @param array $certificate certificate configuration
|
* @param array $certificate certificate configuration
|
||||||
* @param string $server server to use for issuance
|
* @param string $server server to use for issuance
|
||||||
* @param string $storage storage directory
|
* @param string $storage storage directory
|
||||||
|
* @param int|null $concurrency concurrent challenges
|
||||||
* @return \Generator
|
* @return \Generator
|
||||||
* @throws AcmeException if something does wrong
|
* @throws AcmeException if something does wrong
|
||||||
*/
|
*/
|
||||||
private function checkAndIssue(array $certificate, $server, $storage) {
|
private function checkAndIssue(array $certificate, $server, $storage, $concurrency = null) {
|
||||||
$domainPathMap = $this->toDomainPathMap($certificate["paths"]);
|
$domainPathMap = $this->toDomainPathMap($certificate["paths"]);
|
||||||
$domains = array_keys($domainPathMap);
|
$domains = array_keys($domainPathMap);
|
||||||
$commonName = reset($domains);
|
$commonName = reset($domains);
|
||||||
@@ -230,6 +233,11 @@ class Auto implements Command {
|
|||||||
$args[] = $certificate["bits"];
|
$args[] = $certificate["bits"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($concurrency) {
|
||||||
|
$args[] = "--challenge-concurrency";
|
||||||
|
$args[] = $concurrency;
|
||||||
|
}
|
||||||
|
|
||||||
$command = implode(" ", array_map("escapeshellarg", $args));
|
$command = implode(" ", array_map("escapeshellarg", $args));
|
||||||
|
|
||||||
$process = new Process($command);
|
$process = new Process($command);
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ class Issue implements Command {
|
|||||||
$acme = $this->acmeFactory->build($server, $keyPair);
|
$acme = $this->acmeFactory->build($server, $keyPair);
|
||||||
$errors = [];
|
$errors = [];
|
||||||
|
|
||||||
$domainChunks = array_chunk($domains, 10, true);
|
$concurrency = $args->get("challenge-concurrency");
|
||||||
|
|
||||||
|
$domainChunks = array_chunk($domains, \min(20, \max($concurrency, 1)), true);
|
||||||
|
|
||||||
foreach ($domainChunks as $domainChunk) {
|
foreach ($domainChunks as $domainChunk) {
|
||||||
$promises = [];
|
$promises = [];
|
||||||
@@ -251,6 +253,12 @@ class Issue implements Command {
|
|||||||
"defaultValue" => 2048,
|
"defaultValue" => 2048,
|
||||||
"castTo" => "int",
|
"castTo" => "int",
|
||||||
],
|
],
|
||||||
|
"challenge-concurrency" => [
|
||||||
|
"longPrefix" => "challenge-concurrency",
|
||||||
|
"description" => "Number of challenges to be solved concurrently.",
|
||||||
|
"defaultValue" => 10,
|
||||||
|
"castTo" => "int",
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user