Skip to content

Commit

Permalink
IBX-9316: Fixed cpu count for cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
reithor committed Dec 10, 2024
1 parent e8dc468 commit 1c739fc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bundle/Core/Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1c739fc

Please sign in to comment.