From: Vincent Vanwaelscappel Date: Thu, 20 Jul 2023 10:43:47 +0000 (+0200) Subject: wip #6150 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=5e09a3deb61ff9cf8e954f9c95dbf5fb14389233;p=fluidbook-toolbox.git wip #6150 @0.25 --- diff --git a/app/Fluidbook/Farm.php b/app/Fluidbook/Farm.php index de638b318..1284f3063 100644 --- a/app/Fluidbook/Farm.php +++ b/app/Fluidbook/Farm.php @@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Log; class Farm { - protected static $_forceServer = false; + protected static $_forceServer = 'alphaville'; protected static $_farmServers = [ ['name' => 'alphaville', 'host' => 'fluidbook-processfarm', 'port' => 9000, 'weight' => 24, 'region' => 'UE'], ['name' => 'brazil', 'host' => 'brazil.cubedesigners.com', 'weight' => 2, 'region' => 'US'], @@ -50,14 +50,6 @@ class Farm public static function pickOneServer() { - if (self::$_forceServer) { - foreach (self::$_farmServers as $farmServer) { - if ($farmServer['name'] === self::$_forceServer) { - return $farmServer; - } - } - } - $hat = []; $pingCache = self::_pingCache(); if (!file_exists($pingCache)) { @@ -69,6 +61,9 @@ class Farm if (!isset($pings[$k]) || !$pings[$k]) { continue; } + if (self::$_forceServer && $farmServer['name'] === self::$_forceServer) { + return $farmServer; + } for ($i = 0; $i < $farmServer['weight']; $i++) { $hat[] = $k; } @@ -110,7 +105,7 @@ class Farm return self::_getFile($params); } - public static function getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText = true, $withGraphics = true, $version = 'html', $out = null, $force = false) + public static function getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText = true, $withGraphics = true, $version = 'html', $out = null, $force = false, $attemps = 3) { if (null === $out) { $hash = Files::hashFileAttributes($pdf); @@ -140,8 +135,8 @@ class Farm $res = Cache::rememberForever($cachekey, function () use ($params) { return self::_getFile($params); }); - if (!$res) { - Cache::forget($cachekey); + if ((!$res || !file_exists($res))) { + return self::getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText, $withGraphics, $version, $out, true, $attemps - 1); } return $res; }