Skip to content

Commit 667d8a1

Browse files
authored
[Bref] Signal to AWS if we fail to initialize the application (#96)
* Signal to AWS if we fail to initialize the application * cs
1 parent f345324 commit 667d8a1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Runtime.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Contracts\Http\Kernel;
99
use Psr\Container\ContainerInterface;
1010
use Psr\Http\Server\RequestHandlerInterface;
11+
use Runtime\Bref\Lambda\LambdaClient;
1112
use Symfony\Component\Console\Application;
1213
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
1314
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -32,6 +33,20 @@ public function __construct(array $options = [])
3233
}
3334

3435
public function getRunner(?object $application): RunnerInterface
36+
{
37+
try {
38+
return $this->tryToFindRunner($application);
39+
} catch (\Throwable $e) {
40+
if ('aws' === $this->options['bref_runner_type']) {
41+
$lambda = LambdaClient::fromEnvironmentVariable('symfony-runtime');
42+
$lambda->failInitialization('Could not get the Runtime runner.', $e);
43+
}
44+
45+
throw $e;
46+
}
47+
}
48+
49+
private function tryToFindRunner(?object $application)
3550
{
3651
if ($application instanceof ContainerInterface) {
3752
$handler = explode(':', $_SERVER['_HANDLER']);

0 commit comments

Comments
 (0)