From fb1cc1a0cc13489bff4e83b84918f2bc6ea27d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 26 Jun 2023 10:11:13 +0200 Subject: [PATCH] Cold-start improvements --- app/controllers/api/functions.php | 4 ++-- app/workers/functions.php | 4 ++-- src/Executor/Executor.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index a0e54eb14c..a90c93f5e9 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1521,7 +1521,7 @@ App::post('/v1/functions/:functionId/executions') /** Execute function */ $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); try { - $command = 'npm start'; // TODO: Custom for each runtime + $command = 'node src/server.js'; // TODO: Custom for each runtime $executionResponse = $executor->createExecution( projectId: $project->getId(), deploymentId: $deployment->getId(), @@ -1535,7 +1535,7 @@ App::post('/v1/functions/:functionId/executions') path: $path, method: $method, headers: $headers, - command: 'cp /tmp/code.tar.gz /mnt/code/code.tar.gz && nohup helpers/start.sh "' . $command . '" &>/dev/null &' + runtimeEntrypoint: 'cp /tmp/code.tar.gz /mnt/code/code.tar.gz && nohup helpers/start.sh "' . $command . '"' ); /** Update execution status */ diff --git a/app/workers/functions.php b/app/workers/functions.php index c45212bc63..a737d9cdad 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -166,7 +166,7 @@ Server::setResource('execute', function () { /** Execute function */ try { - $command = 'npm start'; // TODO: Custom for each runtime + $command = 'node src/server.js'; // TODO: Custom for each runtime $client = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); $executionResponse = $client->createExecution( projectId: $project->getId(), @@ -181,7 +181,7 @@ Server::setResource('execute', function () { path: $path, method: $method, headers: $headers, - command: 'cp /tmp/code.tar.gz /mnt/code/code.tar.gz && nohup helpers/start.sh "' . $command . '" &>/dev/null &' + runtimeEntrypoint: 'cp /tmp/code.tar.gz /mnt/code/code.tar.gz && nohup helpers/start.sh "' . $command . '"' ); $status = $executionResponse['statusCode'] >= 400 ? 'failed' : 'completed'; diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 0571bc21ee..ebec3bd785 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -162,7 +162,7 @@ class Executor * @param string $image * @param string $source * @param string $entrypoint - * @param string $command + * @param string $runtimeEntrypoint * * @return array */ @@ -179,7 +179,7 @@ class Executor string $path, string $method, array $headers, - string $command = null, + string $runtimeEntrypoint = null, ) { $headers['host'] = App::getEnv('_APP_DOMAIN', ''); @@ -200,7 +200,7 @@ class Executor 'cpus' => $this->cpus, 'memory' => $this->memory, 'version' => $version, - 'command' => $command, + 'runtimeEntrypoint' => $runtimeEntrypoint, ]; $timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);