Skip to content

Commit ab65915

Browse files
committed
fix: balancing
1 parent 1c9e2eb commit ab65915

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/http.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ function createState(string $dsn): State
156156
$balancer->addFilter(function ($option) use ($runtimeId) {
157157
$runtimes = $option->getState('runtimes', []);
158158
$runtime = $runtimes[$runtimeId] ?? [];
159-
return ($runtime['usage'] ?? 100) < 80;
159+
return ($runtime['usage'] ?? 100) < 80
160+
&& $runtime['status'] === 'pass';
160161
});
161162
$balancers[] = $balancer;
162163
}
@@ -471,7 +472,7 @@ function logError(Throwable $error, string $action, ?Logger $logger, Route $rout
471472
CURLE_SEND_ERROR, // Failed to send request - runtime might be overloaded or in a bad state
472473
CURLE_GOT_NOTHING // Empty response - runtime likely crashed after accepting the connection
473474
])) {
474-
$state->save(RESOURCE_RUNTIMES . $hostname, $runtimeId, 'fail', 0);
475+
$state->save(RESOURCE_RUNTIMES . $hostname, $runtimeId, 'offline', 100);
475476
Console::warning("Runtime '$runtimeId' on executor '$hostname' encountered an error (Error $errNo: $error). Removed from state.");
476477
}
477478

0 commit comments

Comments
 (0)