Skip to content

Commit 03952ee

Browse files
committed
feat: dynamically adjust wp command timeout using console config
1 parent f24df38 commit 03952ee

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Command/AbstractInvocationCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class AbstractInvocationCommand extends AbstractProjectCommand
2424
/**
2525
* Invokes the given environment console function with the given payload and returns the output.
2626
*/
27-
protected function invokeEnvironmentFunction(string $environment, array $payload): array
27+
protected function invokeEnvironmentFunction(string $environment, array $payload, int $timeout = 60): array
2828
{
2929
$invocationId = $this->apiClient->createInvocation($this->projectConfiguration->getProjectId(), $environment, $payload)->get('id');
3030

@@ -36,7 +36,7 @@ protected function invokeEnvironmentFunction(string $environment, array $payload
3636
$invocation = $this->apiClient->getInvocation($invocationId);
3737

3838
return !in_array($invocation->get('status'), ['pending', 'running']) ? $invocation : [];
39-
});
39+
}, $timeout);
4040

4141
if ('failed' === $invocation['status']) {
4242
throw new RuntimeException('Running the command failed');

src/Command/WpCliCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Input\InputArgument;
1818
use Symfony\Component\Console\Input\InputInterface;
1919
use Symfony\Component\Console\Input\InputOption;
20+
use Tightenco\Collect\Support\Arr;
2021
use Ymir\Cli\Console\ConsoleOutput;
2122

2223
class WpCliCommand extends AbstractInvocationCommand
@@ -64,7 +65,7 @@ protected function perform(InputInterface $input, ConsoleOutput $output)
6465

6566
$result = $this->invokeEnvironmentFunction($environment, [
6667
'php' => sprintf('bin/wp %s', $command),
67-
]);
68+
], Arr::get((array) $this->projectConfiguration->getEnvironment($environment), 'console.timeout', 60));
6869

6970
$output->newLine();
7071
$output->write("${result['output']}");

0 commit comments

Comments
 (0)