1
0
Fork 0
mirror of synced 2024-06-03 03:14:50 +12:00

Update to handle runtimes becoming more generic

This commit is contained in:
Bradley Schofield 2022-01-11 14:05:50 +00:00
parent 2a6de25f28
commit 0b2c4832f5
2 changed files with 6 additions and 6 deletions

View file

@ -291,7 +291,7 @@ App::post('/v1/tag')
'stderr' => '',
'buildTime' => 0,
'envVars' => [
'APPWRITE_ENTRYPOINT_NAME' => $tag->getAttribute('entrypoint'),
'ENTRYPOINT_NAME' => $tag->getAttribute('entrypoint'),
'APPWRITE_FUNCTION_ID' => $function->getId(),
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'],
@ -705,7 +705,7 @@ function createRuntimeServer(string $functionId, string $projectId, string $tagI
'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'],
'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'],
'APPWRITE_FUNCTION_PROJECT_ID' => $projectId,
'APPWRITE_INTERNAL_RUNTIME_KEY' => $secret
'INTERNAL_RUNTIME_KEY' => $secret
]);
$vars = \array_merge($vars, $build->getAttribute('envVars', [])); // for gettng endpoint.
@ -931,7 +931,7 @@ function execute(string $trigger, string $projectId, string $executionId, string
'stderr' => '',
'buildTime' => 0,
'envVars' => [
'APPWRITE_ENTRYPOINT_NAME' => $tag->getAttribute('entrypoint'),
'ENTRYPOINT_NAME' => $tag->getAttribute('entrypoint'),
'APPWRITE_FUNCTION_ID' => $function->getId(),
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'],
@ -1027,7 +1027,7 @@ function execute(string $trigger, string $projectId, string $executionId, string
$body = \json_encode([
'path' => '/usr/code',
'file' => $build->getAttribute('envVars', [])['APPWRITE_ENTRYPOINT_NAME'],
'file' => $build->getAttribute('envVars', [])['ENTRYPOINT_NAME'],
'env' => $vars,
'payload' => $data,
'timeout' => $function->getAttribute('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900))

View file

@ -53,7 +53,7 @@ The `launch.sh` file for an interpreted runtime should extract the `/tmp/code.ta
---
Compiled Languages only have a `build.sh` file.
The `build.sh` script for a compiled runtime is used to move the user's source code and rename it into source files for the runtime (The `APPWRITE_ENTRYPOINT_NAME` environment variable can help with this) it will also build the code and move it into the `/usr/code` folder. Compiled runtime executables **must** be called `runtime` for the ubuntu or alpine images to detect and run them.
The `build.sh` script for a compiled runtime is used to move the user's source code and rename it into source files for the runtime (The `ENTRYPOINT_NAME` environment variable can help with this) it will also build the code and move it into the `/usr/code` folder. Compiled runtime executables **must** be called `runtime` for the ubuntu or alpine images to detect and run them.
#### Note:
`/tmp/code.tar.gz` is always created from the `/usr/code` folder in the build stage. If you need any files for either compiled or interpreted runtimes you should place them there and extract them from the `/tmp/code.tar.gz` during the `launch.sh` script to get the files you need.
@ -63,7 +63,7 @@ Internally the runtime can be anything you like as long as it follows the standa
The best way to go about writing a runtime is like so:
Initialize a web server that runs on port 3000 and uses any IP Address (0.0.0.0) and on each `POST` request do the following:
1. Check that the `x-internal-challenge` header matches the `APPWRITE_INTERNAL_RUNTIME_KEY` environment variable. If not return an error with a `401` status code and an `unauthorized` error message.
1. Check that the `x-internal-challenge` header matches the `INTERNAL_RUNTIME_KEY` environment variable. If not return an error with a `401` status code and an `unauthorized` error message.
2. Decode the executor's JSON POST request. This normally looks like so:
```json
{