diff --git a/app/config/variables.php b/app/config/variables.php index bcec88f9e3..e842283c2c 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -339,15 +339,15 @@ return [ ], [ 'name' => '_APP_FUNCTIONS_CPUS', - 'description' => 'The maximum number of CPU core a single cloud function is allowed to use. Please note that setting a value higher than available cores will result in a function error, which might result in an error. The default value is 1.', + 'description' => 'The maximum number of CPU core a single cloud function is allowed to use. Please note that setting a value higher than available cores will result in a function error, which might result in an error. The default value is empty. When it\'s empty, CPU limit will be disabled.', 'introduction' => '0.7.0', - 'default' => '1', + 'default' => '', 'required' => false, 'question' => '', ], [ 'name' => '_APP_FUNCTIONS_MEMORY', - 'description' => 'The maximum amount of memory a single cloud function is allowed to use in megabytes. The default value is 128.', + 'description' => 'The maximum amount of memory a single cloud function is allowed to use in megabytes. The default value is empty. When it\'s empty, memory limit will be disabled.', 'introduction' => '0.7.0', 'default' => '256', 'required' => false, @@ -355,7 +355,7 @@ return [ ], [ 'name' => '_APP_FUNCTIONS_MEMORY_SWAP', - 'description' => 'The maximum amount of swap memory a single cloud function is allowed to use in megabytes. The default value is 128.', + 'description' => 'The maximum amount of swap memory a single cloud function is allowed to use in megabytes. The default value is empty. When it\'s empty, swap memory limit will be disabled.', 'introduction' => '0.7.0', 'default' => '256', 'required' => false, diff --git a/app/workers/functions.php b/app/workers/functions.php index 71c5d8a7ab..99a8a47703 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -397,13 +397,15 @@ class FunctionsV1 $executionStart = \microtime(true); $executionTime = \time(); - + $cpus = App::getEnv('_APP_FUNCTIONS_CPUS', ''); + $memory = App::getEnv('_APP_FUNCTIONS_MEMORY', ''); + $swap = App::getEnv('_APP_FUNCTIONS_MEMORY_SWAP', ''); $exitCode = Console::execute("docker run ". " -d". " --entrypoint=\"\"". - " --cpus=".App::getEnv('_APP_FUNCTIONS_CPUS', '1'). - " --memory=".App::getEnv('_APP_FUNCTIONS_MEMORY', '256')."m". - " --memory-swap=".App::getEnv('_APP_FUNCTIONS_MEMORY_SWAP', '256')."m". + (empty($cpus) ? "" : (" --cpus=".$cpus)). + (empty($memory) ? "" : (" --memory=".$memory."m")). + (empty($swap) ? "" : (" --memory-swap=".$swap."m")). " --name={$container}". " --label appwrite-type=function". " --label appwrite-created={$executionTime}".