From 47769cefae1ac8acb3e06c818260d64b8ec41a4b Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 14 Dec 2020 20:04:57 +0200 Subject: [PATCH] Added new env vars --- .env | 3 +++ Dockerfile | 3 +++ app/config/variables.php | 18 ++++++++++++++++++ app/views/install/compose.phtml | 6 ++++++ app/workers/functions.php | 6 +++--- docker-compose.yml | 6 ++++++ tests/resources/docker/docker-compose.yml | 6 ++++++ 7 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.env b/.env index 9764cfe89..f881ca35d 100644 --- a/.env +++ b/.env @@ -27,3 +27,6 @@ _APP_SMTP_PASSWORD= _APP_STORAGE_LIMIT=10000000 _APP_FUNCTIONS_TIMEOUT=900 _APP_FUNCTIONS_CONTAINERS=10 +_APP_FUNCTIONS_CPUS=1 +_APP_FUNCTIONS_MEMORY=128 +_APP_FUNCTIONS_MEMORY_SWAP=128 diff --git a/Dockerfile b/Dockerfile index d41dbc50f..fc7a03f93 100755 --- a/Dockerfile +++ b/Dockerfile @@ -92,6 +92,9 @@ ENV _APP_SERVER=swoole \ _APP_SMTP_PORT=25 \ _APP_FUNCTIONS_TIMEOUT=900 \ _APP_FUNCTIONS_CONTAINERS=10 \ + _APP_FUNCTIONS_CPUS=1 \ + _APP_FUNCTIONS_MEMORY=128 \ + _APP_FUNCTIONS_MEMORY_SWAP=128 \ _APP_SETUP=self-hosted \ _APP_VERSION=$VERSION #ENV _APP_SMTP_SECURE '' diff --git a/app/config/variables.php b/app/config/variables.php index 3da5a21e2..f752e9020 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -151,4 +151,22 @@ return [ 'required' => false, 'question' => '', ], + [ + 'name' => '_APP_FUNCTIONS_CPUS', + 'default' => '1', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_FUNCTIONS_MEMORY', + 'default' => '128', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_FUNCTIONS_MEMORY_SWAP', + 'default' => '128', + 'required' => false, + 'question' => '', + ], ]; \ No newline at end of file diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 045f29e63..4fee9a4bb 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -77,6 +77,9 @@ services: - _APP_STORAGE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_CONTAINERS + - _APP_FUNCTIONS_CPUS + - _APP_FUNCTIONS_MEMORY + - _APP_FUNCTIONS_MEMORY_SWAP appwrite-worker-usage: image: appwrite/appwrite: @@ -229,6 +232,9 @@ services: - _APP_DB_PASS - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_CONTAINERS + - _APP_FUNCTIONS_CPUS + - _APP_FUNCTIONS_MEMORY + - _APP_FUNCTIONS_MEMORY_SWAP appwrite-worker-mails: image: appwrite/appwrite: diff --git a/app/workers/functions.php b/app/workers/functions.php index a4f128445..510aed092 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -387,9 +387,9 @@ class FunctionsV1 $exitCode = Console::execute("docker run \ -d \ --entrypoint=\"\" \ - --cpus=1 \ - --memory=128m \ - --memory-swap=128m \ + --cpus=".App::getEnv('_APP_FUNCTIONS_CPUS', '1')." \ + --memory=".App::getEnv('_APP_FUNCTIONS_MEMORY', '128')."m \ + --memory-swap=".App::getEnv('_APP_FUNCTIONS_MEMORY_SWAP', '128')."m \ --name={$container} \ --label appwrite-type=function \ --label appwrite-created=".$executionTime." \ diff --git a/docker-compose.yml b/docker-compose.yml index 5e8c6bd53..da4af6d9f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -91,6 +91,9 @@ services: - _APP_STORAGE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_CONTAINERS + - _APP_FUNCTIONS_CPUS + - _APP_FUNCTIONS_MEMORY + - _APP_FUNCTIONS_MEMORY_SWAP appwrite-worker-usage: entrypoint: worker-usage @@ -270,6 +273,9 @@ services: - _APP_DB_PASS - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_CONTAINERS + - _APP_FUNCTIONS_CPUS + - _APP_FUNCTIONS_MEMORY + - _APP_FUNCTIONS_MEMORY_SWAP appwrite-worker-mails: entrypoint: worker-mails diff --git a/tests/resources/docker/docker-compose.yml b/tests/resources/docker/docker-compose.yml index eacb4ec1a..b9171dadb 100644 --- a/tests/resources/docker/docker-compose.yml +++ b/tests/resources/docker/docker-compose.yml @@ -83,6 +83,9 @@ services: - _APP_STORAGE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_CONTAINERS + - _APP_FUNCTIONS_CPUS + - _APP_FUNCTIONS_MEMORY + - _APP_FUNCTIONS_MEMORY_SWAP appwrite-worker-usage: entrypoint: worker-usage @@ -239,6 +242,9 @@ services: - _APP_DB_PASS - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_CONTAINERS + - _APP_FUNCTIONS_CPUS + - _APP_FUNCTIONS_MEMORY + - _APP_FUNCTIONS_MEMORY_SWAP appwrite-worker-mails: entrypoint: worker-mails