Add support for all runtime start commands

This commit is contained in:
Matej Bačo
2023-07-24 08:23:23 +02:00
parent 9484994c4c
commit e5adc5772c
8 changed files with 21 additions and 19 deletions
+2 -2
View File
@@ -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(),
+1 -1
View File
@@ -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')
-2
View File
@@ -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 {
-3
View File
@@ -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);
+3 -3
View File
@@ -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'),
+1 -1
View File
@@ -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.*",
Generated
+13 -6
View File
@@ -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