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'],
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)) {
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;
}
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);
$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;
}