From e5adc5772cf07ae761b16aa52d74adf842e7e55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 24 Jul 2023 08:23:23 +0200 Subject: [PATCH] Add support for all runtime start commands --- app/console | 2 +- app/controllers/api/functions.php | 4 ++-- app/controllers/api/vcs.php | 2 +- app/controllers/general.php | 2 -- app/workers/builds.php | 3 --- app/workers/functions.php | 6 +++--- composer.json | 2 +- composer.lock | 19 +++++++++++++------ 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/app/console b/app/console index d358c7df6e..65bd2441e6 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit d358c7df6e0cb2e6826d519dc7b069da9a6f84b0 +Subproject commit 65bd2441e69662a1275f123df0d02709bc0f8613 diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 1233b5cd0a..9623be0e85 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -911,7 +911,7 @@ App::post('/v1/functions/:functionId/deployments') ->inject('deviceLocal') ->action(function (string $functionId, mixed $code, mixed $activate, Request $request, Response $response, Database $dbForProject, Event $events, Document $project, Device $deviceFunctions, Device $deviceLocal) { $activate = filter_var($activate, FILTER_VALIDATE_BOOLEAN); - + $function = $dbForProject->getDocument('functions', $functionId); if ($function->isEmpty()) { @@ -1515,7 +1515,7 @@ App::post('/v1/functions/:functionId/executions') /** Execute function */ $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); try { - $command = 'node src/server.js'; // TODO: Custom for each runtime + $command = $runtime['startCommand']; $executionResponse = $executor->createExecution( projectId: $project->getId(), deploymentId: $deployment->getId(), diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index e4692c83be..2a56b57ef9 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -65,7 +65,7 @@ App::get('/v1/vcs/github/installations') $prefs['vcsState'] = $state; $user->setAttribute('prefs', $prefs); $dbForConsole->updateDocument('users', $user->getId(), $user); - + $appName = App::getEnv('VCS_GITHUB_APP_NAME'); $response ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') diff --git a/app/controllers/general.php b/app/controllers/general.php index 063ef9aebc..09fbf32d6b 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -494,8 +494,6 @@ App::error() $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); $route = $utopia->getRoute(); - \var_dump($route->getPath()); - if ($logger) { if ($error->getCode() >= 500 || $error->getCode() === 0) { try { diff --git a/app/workers/builds.php b/app/workers/builds.php index a008590f65..15ee66cc05 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -174,9 +174,7 @@ class BuildsV1 extends Worker $cloneRepository = !empty($vcsContribution) ? $vcsContribution->getAttribute('repositoryName', $repositoryName) : $repositoryName; $branchName = $deployment->getAttribute('vcsBranch'); - var_dump("root " . $rootDirectory); $gitCloneCommand = $github->generateCloneCommand($cloneOwner, $cloneRepository, $branchName, $tmpDirectory, $rootDirectory); - var_dump($gitCloneCommand); $stdout = ''; $stderr = ''; Console::execute('mkdir -p /tmp/builds/' . $buildId, '', $stdout, $stderr); @@ -364,7 +362,6 @@ class BuildsV1 extends Worker projectId: $project->getId(), deploymentId: $deployment->getId(), callback: function ($logs) use (&$response, &$build, $dbForProject, $allEvents, $project) { - \var_dump("Got logs"); if ($response === null) { $build = $build->setAttribute('stdout', $build->getAttribute('stdout', '') . $logs); $build = $dbForProject->updateDocument('builds', $build->getId(), $build); diff --git a/app/workers/functions.php b/app/workers/functions.php index a737d9cdad..53fbf57ac4 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -166,9 +166,9 @@ Server::setResource('execute', function () { /** Execute function */ try { - $command = 'node src/server.js'; // TODO: Custom for each runtime - $client = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); - $executionResponse = $client->createExecution( + $command = $runtime['startCommand']; + $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); + $executionResponse = $executor->createExecution( projectId: $project->getId(), deploymentId: $deploymentId, version: $function->getAttribute('version'), diff --git a/composer.json b/composer.json index 0f2e22d511..5ab2dfe9ad 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "ext-zlib": "*", "ext-sockets": "*", "appwrite/php-clamav": "1.1.*", - "appwrite/php-runtimes": "0.11.*", + "appwrite/php-runtimes": "dev-feat-add-start-commands as 0.11.99", "utopia-php/abuse": "0.16.*", "utopia-php/analytics": "0.10.2", "utopia-php/audit": "0.17.*", diff --git a/composer.lock b/composer.lock index 93e6c7e331..b8f9c174b4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4478e6ea7546002b03722b73527f1286", + "content-hash": "9ce42ed4bf5a5223e421a89be9a261cd", "packages": [ { "name": "adhocore/jwt", @@ -115,11 +115,11 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.11.1", + "version": "dev-feat-add-start-commands", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "9d74a477ba3333cbcfac565c46fcf19606b7b603" + "reference": "7e9e40dcf4cbdb483f0e20bf2e99b844554a533c" }, "require": { "php": ">=8.0", @@ -154,7 +154,7 @@ "php", "runtimes" ], - "time": "2022-11-07T16:45:52+00:00" + "time": "2023-07-22T16:31:06+00:00" }, { "name": "chillerlan/php-qrcode", @@ -2705,7 +2705,7 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "c836cb55c2d3e0e28506228c55a6c6efcb16ddbd" + "reference": "20d39035360f757da355374b59d374fc4dc80a5a" }, "require": { "adhocore/jwt": "^1.1", @@ -2754,7 +2754,7 @@ "utopia", "vcs" ], - "time": "2023-07-20T12:42:56+00:00" + "time": "2023-07-21T11:31:42+00:00" }, { "name": "utopia-php/websocket", @@ -5496,6 +5496,12 @@ } ], "aliases": [ + { + "package": "appwrite/php-runtimes", + "version": "dev-feat-add-start-commands", + "alias": "0.11.99", + "alias_normalized": "0.11.99.0" + }, { "package": "appwrite/sdk-generator", "version": "dev-feat-add-path-keyword", @@ -5517,6 +5523,7 @@ ], "minimum-stability": "stable", "stability-flags": { + "appwrite/php-runtimes": 20, "utopia-php/framework": 20, "utopia-php/vcs": 20, "appwrite/sdk-generator": 20