Skip to content

Commit

Permalink
fix-cs
Browse files Browse the repository at this point in the history
  • Loading branch information
reithor committed Dec 10, 2024
1 parent 1c739fc commit f420587
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bundle/Core/Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,16 @@ private function getPhpPath()
private function getNumberOfCPUCores()
{
$cores = 1;
if (isset($_SERVER['PLATFORM_BRANCH']) && is_file( '/run/config.json')) {
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');
if ($config_json_encoded == false) {
return 1;
}
$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;

return (int)$cores;
} elseif (is_file('/proc/cpuinfo')) {
// Linux (and potentially Windows with linux sub systems)
$cpuinfo = file_get_contents('/proc/cpuinfo');
Expand Down

0 comments on commit f420587

Please sign in to comment.