mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Cold-start improvements
This commit is contained in:
parent
20e3eb78fb
commit
fb1cc1a0cc
3 changed files with 7 additions and 7 deletions
|
|
@ -1521,7 +1521,7 @@ App::post('/v1/functions/:functionId/executions')
|
||||||
/** Execute function */
|
/** Execute function */
|
||||||
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
||||||
try {
|
try {
|
||||||
$command = 'npm start'; // TODO: Custom for each runtime
|
$command = 'node src/server.js'; // TODO: Custom for each runtime
|
||||||
$executionResponse = $executor->createExecution(
|
$executionResponse = $executor->createExecution(
|
||||||
projectId: $project->getId(),
|
projectId: $project->getId(),
|
||||||
deploymentId: $deployment->getId(),
|
deploymentId: $deployment->getId(),
|
||||||
|
|
@ -1535,7 +1535,7 @@ App::post('/v1/functions/:functionId/executions')
|
||||||
path: $path,
|
path: $path,
|
||||||
method: $method,
|
method: $method,
|
||||||
headers: $headers,
|
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 */
|
/** Update execution status */
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ Server::setResource('execute', function () {
|
||||||
|
|
||||||
/** Execute function */
|
/** Execute function */
|
||||||
try {
|
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'));
|
$client = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
||||||
$executionResponse = $client->createExecution(
|
$executionResponse = $client->createExecution(
|
||||||
projectId: $project->getId(),
|
projectId: $project->getId(),
|
||||||
|
|
@ -181,7 +181,7 @@ Server::setResource('execute', function () {
|
||||||
path: $path,
|
path: $path,
|
||||||
method: $method,
|
method: $method,
|
||||||
headers: $headers,
|
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';
|
$status = $executionResponse['statusCode'] >= 400 ? 'failed' : 'completed';
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ class Executor
|
||||||
* @param string $image
|
* @param string $image
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $entrypoint
|
* @param string $entrypoint
|
||||||
* @param string $command
|
* @param string $runtimeEntrypoint
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|
@ -179,7 +179,7 @@ class Executor
|
||||||
string $path,
|
string $path,
|
||||||
string $method,
|
string $method,
|
||||||
array $headers,
|
array $headers,
|
||||||
string $command = null,
|
string $runtimeEntrypoint = null,
|
||||||
) {
|
) {
|
||||||
$headers['host'] = App::getEnv('_APP_DOMAIN', '');
|
$headers['host'] = App::getEnv('_APP_DOMAIN', '');
|
||||||
|
|
||||||
|
|
@ -200,7 +200,7 @@ class Executor
|
||||||
'cpus' => $this->cpus,
|
'cpus' => $this->cpus,
|
||||||
'memory' => $this->memory,
|
'memory' => $this->memory,
|
||||||
'version' => $version,
|
'version' => $version,
|
||||||
'command' => $command,
|
'runtimeEntrypoint' => $runtimeEntrypoint,
|
||||||
];
|
];
|
||||||
|
|
||||||
$timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);
|
$timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue