Skip to content

Commit

Permalink
Added timeout params.
Browse files Browse the repository at this point in the history
  • Loading branch information
lotharthesavior committed Aug 25, 2023
1 parent 239d763 commit 7149318
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/jacked-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
'host' => env('JACKED_SERVER_HOST', '0.0.0.0'),
'port' => env('JACKED_SERVER_PORT', 8080),
'server-type' => env('JACKED_SERVER_SERVER_TYPE', Server::POOL_MODE),
'timeout' => env('JACKED_SERVER_TIMEOUT', 60),
'readwrite-timeout' => env('JACKED_SERVER_READWRITE_TIMEOUT', 60),

// ------------------------------------------------------------
// SSL
Expand Down
13 changes: 11 additions & 2 deletions src/Services/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function run(): void
// reactor and workers
'reactor_num' => Util::getCPUNum() + 2,
'worker_num' => Util::getCPUNum() + 2,
// timeout
'max_request_execution_time' => config('jacked-server.timeout', 60),
]), ($ssl ? [
'ssl_cert_file' => config('jacked-server.ssl-cert-file'),
'ssl_key_file' => config('jacked-server.ssl-key-file'),
Expand Down Expand Up @@ -401,10 +403,17 @@ private function executeRequest(array $requestOptions, string $content): JackedR
$this->logger->info($this->logPrefix . 'Request Time: {time}', [
'time' => Carbon::now()->format('Y-m-d H:i:s'),
]);
$result = (new Client(
$client = new Client(
host: config('jacked-server.fastcgi.host', '127.0.0.1'),
port: config('jacked-server.fastcgi.port', 9000),
))->request($requestOptions, $content);
);
$client->setConnectTimeout(
config('jacked-server.timeout', 60) * 1000,
);
$client->setReadWriteTimeout(
config('jacked-server.readwrite-timeout', 60) * 1000,
);
$result = ($client)->request($requestOptions, $content);
} catch (Exception $e) {
$error = $e->getMessage();

Expand Down

0 comments on commit 7149318

Please sign in to comment.