(fix): run install tracking in coroutine to avoid blocking worker

This commit is contained in:
Jake Barnby
2026-03-31 14:59:31 +13:00
parent 7bcd5b4ebc
commit a955dff55a
2 changed files with 15 additions and 1 deletions
@@ -6,6 +6,7 @@ use Appwrite\Platform\Installer\Http\Installer\Error;
use Appwrite\Platform\Installer\Runtime\Config;
use Appwrite\Platform\Installer\Runtime\State;
use Swoole\Http\Server as SwooleServer;
use Swoole\Runtime;
use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Http\Adapter\Swoole\Response;
use Utopia\Http\Adapter\Swoole\Server as SwooleAdapter;
@@ -129,6 +130,8 @@ class Server
private function startSwooleServer(string $host, int $port, ?string $readyFile = null): void
{
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
$this->state->clearStaleLock();
// Preload static files into memory
+12 -1
View File
@@ -7,6 +7,7 @@ use Appwrite\Docker\Env;
use Appwrite\Platform\Installer\Runtime\State;
use Appwrite\Platform\Installer\Server as InstallerServer;
use Appwrite\Utopia\View;
use Swoole\Coroutine;
use Utopia\Auth\Proofs\Password;
use Utopia\Auth\Proofs\Token;
use Utopia\Config\Config;
@@ -643,7 +644,17 @@ class Install extends Action
}
}
$this->trackSelfHostedInstall($input, $isUpgrade, $version, $account);
// Run tracking in a coroutine (web installer) so it
// doesn't block the worker. Safe because the installer
// has no shared mutable state across requests.
// CLI runs synchronously.
if (!$isCLI && Coroutine::getCid() !== -1) {
go(function () use ($input, $isUpgrade, $version, $account) {
$this->trackSelfHostedInstall($input, $isUpgrade, $version, $account);
});
} else {
$this->trackSelfHostedInstall($input, $isUpgrade, $version, $account);
}
if ($isCLI) {
Console::success('Appwrite installed successfully');