From: vincent@cubedesigners.com Date: Fri, 8 Apr 2022 11:51:42 +0000 (+0000) Subject: wip #5220 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=5d4650a90e54293692a69d858f915af82d8294e2;p=cubeextranet.git wip #5220 @1 --- diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 29796cde4..8ce1594ef 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -1816,6 +1816,17 @@ class wsMaintenance } + public static function updateFarm() + { + foreach (wsDocument::getFarmServers() as $farmer) { + echo '

' . $farmer['host'] . '

';
+            $cl = new CubeIT_CommandLine('sudo /usr/local/fluidbook_processfarm/bin/update');
+            $cl->setSSH($farmer['host'], 'fluidbookfarmer', '', $farmer['port'] ?? 22, '/home/extranet/.ssh/id_rsa');
+            $cl->execute();
+            echo $cl->commande . "\n\n--\n\n" . $cl->output . '
'; + } + } + public static function fluidbookFarm($args) { global $core; @@ -1825,7 +1836,27 @@ class wsMaintenance $dao = new wsDAODocument($core->con); $doc = $dao->selectById($doc_id); - $doc->_getFileFarm($page, 'jpg', 150, true, true, 'html', true); + + $files = [ +// ['jpg', 'thumb', true, true, ''], +// ['jpg', '300', true, true, 'html'], +// ['jpg', '150', true, true, 'html'], +// ['jpg', '150', false, true, 'html'], +// ['jpg', '150', false, true, 'html'], +// ['svg', '150', true, false, 'html'], + ['svg', '300', true, false, 'html'], +// ['svg', '150', true, true, 'html'], +// ['svg', '200', true, true, 'html'], + ]; + + foreach ($files as $file) { + echo '

' . json_encode($file) . '

'; + $path = $doc->getFile($page, $file[0], $file[1], $file[2], $file[3], $file[4], true); + echo '

' . $path . '

'; + $path = str_replace('/data1/extranet/www/', 'https://workshop.fluidbook.com/', $path); + echo ''; + } + } diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 77ccfc5a3..7946eeb76 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -55,6 +55,15 @@ class wsDocument extends cubeMetier const MAX = 5; const PNM_FILL = 2; + protected static $_farmServers = [ + ['host' => 'elephantman.cubedesigners.com', 'port' => 22822, 'weight' => 1], + ['host' => 'fastandfurious.cubedesigners.com', 'port' => 22822, 'weight' => 1], + ['host' => 'paris.cubedesigners.com', 'port' => 22922, 'weight' => 1], + ['host' => 'godzilla.cubedesigners.com', 'weight' => 2], + ['host' => 'dracula.cubedesigners.com', 'weight' => 2], + ['host' => 'her.cubedesigners.com', 'weight' => 3], + ]; + protected static $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5); // Number section styles protected static @@ -441,27 +450,47 @@ class wsDocument extends cubeMetier } + public static function getFarmServers() + { + return self::$_farmServers; + } + + public static function pickOneFarmServer() + { + $hat = []; + foreach (self::$_farmServers as $k => $farmServer) { + for ($i = 0; $i < $farmServer['weight']; $i++) { + $hat[] = $k; + } + } + shuffle($hat); + $i = array_pop($hat); + return self::$_farmServers[$i]; + } + public function _getFileFarm($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false) { - $farm = [['host' => 'elephantman.cubedesigners.com', 'port' => 22822]]; - shuffle($farm); - $farmer = array_pop($farm); + $farmer = self::pickOneFarmServer(); - $params = ['page' => $page, 'format' => $format, 'resolution' => $resolution, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, 'force' => $force, 'out' => $this->out,'resolutionRatio'=>$this->getResolutionRatio(),'mobileRatio'=>$this->getMobileFirstRatio()]; - $cl = new CubeIT_CommandLine('/usr/local/fluidbook_processfarm/bin/process'); - $cl->setSSH($farmer['host'], 'fluidbookfarmer', '', $farmer['port'], '/home/extranet/.ssh/id_rsa'); + $params = ['page' => $page, 'format' => $format, 'resolution' => $resolution, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, 'force' => $force, 'out' => $this->out, 'resolutionRatio' => $this->getResolutionRatio(), 'mobileRatio' => $this->getMobileFirstRatio()]; + $cl = new CubeIT_CommandLine('/usr/local/fluidbook_processfarm/bin/process', null, false); + $cl->setSSH($farmer['host'], 'fluidbookfarmer', '', $farmer['port'] ?? 22, '/home/extranet/.ssh/id_rsa'); $cl->setManualArg(base64_encode(json_encode($params))); $cl->execute(); - die($cl->output); + $o = trim($cl->output); + if (file_exists($o)) { + return $o; + } + echo $cl->commande . " : " . $cl->output; + return false; } public function _getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false) { global $core; -// if ($core->user->utilisateur_id == 5) { -// return $this->_getFileFarm($page, $format, $resolution, $withText, $withGraphics, $version, $force); -// } - + if ($core->user->utilisateur_id == 5) { + return $this->_getFileFarm($page, $format, $resolution, $withText, $withGraphics, $version, $force); + } if ($format === 'jpeg') { $format = 'jpg';