Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow developer to control FpmHandler timeout #770

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/Event/Http/FpmHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ final class FpmHandler extends HttpHandler
private $configFile;
/** @var Process|null */
private $fpm;
/** @var int */
private $socketReadWriteTimeout = 30000;

public function __construct(string $handler, string $configFile = self::CONFIG)
{
Expand Down Expand Up @@ -78,7 +80,7 @@ public function start(): void
});

$this->client = new Client;
$this->connection = new UnixDomainSocket(self::SOCKET, 1000, 30000);
$this->connection = new UnixDomainSocket(self::SOCKET, 1000, $this->socketReadWriteTimeout);

$this->waitUntilReady();
}
Expand All @@ -98,6 +100,17 @@ public function __destruct()
$this->stop();
}

/**
* Allow the developer to change the Socket Read Write Timeout to support APIs that take
* longer than 30 seconds to run behing ALB.
*/
public function setSocketReadWriteTimeout(int $timeout): self
{
$this->socketReadWriteTimeout = $timeout;

return $this;
}

/**
* Proxy the API Gateway event to PHP-FPM and return its response.
*/
Expand Down