Cold-start improvements

This commit is contained in:
Matej Bačo 2023-06-26 10:11:13 +02:00
parent 20e3eb78fb
commit fb1cc1a0cc
3 changed files with 7 additions and 7 deletions

View file

@ -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 */

View file

@ -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';

View file

@ -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);