}
+ public static function updateFarm()
+ {
+ foreach (wsDocument::getFarmServers() as $farmer) {
+ echo '<h2>' . $farmer['host'] . '</h2><pre>';
+ $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 . '</pre>';
+ }
+ }
+
public static function fluidbookFarm($args)
{
global $core;
$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 '<h2>' . json_encode($file) . '</h2>';
+ $path = $doc->getFile($page, $file[0], $file[1], $file[2], $file[3], $file[4], true);
+ echo '<p>' . $path . '</p>';
+ $path = str_replace('/data1/extranet/www/', 'https://workshop.fluidbook.com/', $path);
+ echo '<img height="200" src="' . $path . '">';
+ }
+
}
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
}
+ 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';