From 5b9b9cbfa7d3f7fbc0dba61f03a624c089d489c5 Mon Sep 17 00:00:00 2001 From: Thorsten Reiter Date: Tue, 10 Dec 2024 17:09:08 +0100 Subject: [PATCH] IBX-9316: Fixed cpu count for cloud --- src/bundle/Core/Command/ReindexCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bundle/Core/Command/ReindexCommand.php b/src/bundle/Core/Command/ReindexCommand.php index bd8d6cc246..57822a8924 100644 --- a/src/bundle/Core/Command/ReindexCommand.php +++ b/src/bundle/Core/Command/ReindexCommand.php @@ -450,7 +450,13 @@ private function getPhpPath() private function getNumberOfCPUCores() { $cores = 1; - if (is_file('/proc/cpuinfo')) { + if (isset($_SERVER['PLATFORM_BRANCH']) && is_file( '/run/config.json')) { + // Ibexa Cloud: read #cpus from config + $config_json_encoded = file_get_contents('/run/config.json'); + $config_json = json_decode($config_json_encoded); + $cores = isset($config_json->info->limits->cpu) ? max(1, floor($config_json->info->limits->cpu)) : 1; + return $cores; + } elseif (is_file('/proc/cpuinfo')) { // Linux (and potentially Windows with linux sub systems) $cpuinfo = file_get_contents('/proc/cpuinfo'); preg_match_all('/^processor/m', $cpuinfo, $matches);