Skip to content

Commit

Permalink
feat: use nc healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
loks0n committed Oct 22, 2024
1 parent da1d249 commit 77331c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \
# Executor
FROM openruntimes/base:0.1.0 as final

RUN apk add --no-cache netcat-openbsd

ARG OPR_EXECUTOR_VERSION
ENV OPR_EXECUTOR_VERSION=$OPR_EXECUTOR_VERSION

Expand Down
6 changes: 2 additions & 4 deletions app/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Appwrite\Runtimes\Runtimes;
use OpenRuntimes\Executor\BodyMultipart;
use OpenRuntimes\Executor\Validator\TCP;
use OpenRuntimes\Executor\Usage;
use Swoole\Process;
use Swoole\Runtime;
Expand Down Expand Up @@ -1231,15 +1230,14 @@ function (string $runtimeId, ?string $payload, string $path, string $method, mix
if (empty($listening)) {
// Wait for cold-start to finish (app listening on port)
$pingStart = \microtime(true);
$validator = new TCP();
while (true) {
// If timeout is passed, stop and return error
if (\microtime(true) - $pingStart >= $timeout) {
throw new Exception('Function timed out during cold start.', 400);
}

$online = $validator->isValid($hostname . ':' . 3000);
if ($online) {
$status = Console::execute('nc -z ' . $hostname . ' 3000', $output, $errNo);
if ($status === 0) {
break;
}

Expand Down

0 comments on commit 77331c9

Please sign in to comment.