From: vincent@cubedesigners.com Date: Wed, 13 Jul 2022 16:14:25 +0000 (+0000) Subject: wip #4209 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e1f76e412a8eee40e227f4b9ae5ee0480ac42131;p=cubeextranet.git wip #4209 @1 --- diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index c3adc66d0..ccfddfa6d 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -1871,54 +1871,6 @@ class wsMaintenance } - public static function updateFarm() - { - - foreach (wsDocument::getFarmServers() as $id => $farmer) { - echo '

' . $farmer['host'] . ' (' . $id . ')

';
-            $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 pingFarm() - { - $originalConnectionTimeout = ini_get('default_socket_timeout'); - ini_set('default_socket_timeout', 5); - $cache = WS_CACHE . '/farmpings'; - $servers = wsDocument::getFarmServers(); - $pings = []; - if (file_exists($cache)) { - $cached = json_decode(file_get_contents($cache)); - if (count($cached) === count($servers)) { - $pings = $cached; - } - } - - foreach ($servers as $id => $farmer) { - echo '

' . $farmer['name'] . ' (' . $id . ')

'; - if (isset($pings[$id]) && !$pings[$id]) { - // If ping failed recently, we wait a bit before trying again. - if (rand(0, 9) != 5) { - echo '

Skipped, will try again soon

'; - continue; - } - } - - $cl = new CubeIT_CommandLine('/usr/local/fluidbook_processfarm/bin/ping'); - $cl->setSSH($farmer['host'], 'fluidbookfarmer', '', $farmer['port'] ?? 22, '/home/extranet/.ssh/id_rsa'); - $cl->execute(); - $ok = trim($cl->output) == '1'; - echo '

' . ($ok ? 'OK' : 'KO') . ' : ' . $cl->output . '

'; - - $pings[$id] = $ok; - } - file_put_contents($cache, json_encode($pings)); - ini_set('default_socket_timeout', $originalConnectionTimeout); - } - public static function fluidbookFarm($args) { global $core; diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 327b66cf4..14b65395a 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -63,6 +63,7 @@ class wsDocument extends cubeMetier ['name' => 'godzilla', 'host' => 'godzilla.cubedesigners.com', 'weight' => 3], ['name' => 'dracula', 'host' => 'dracula.cubedesigners.com', 'weight' => 3], ['name' => 'her', 'host' => 'her2.cubedesigners.com', 'weight' => 4], + ['name' => 'brazil', 'host' => 'brazil.cubedesigners.com', 'weight' => 6], ]; protected static $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5); @@ -458,7 +459,7 @@ class wsDocument extends cubeMetier public static function pickOneFarmServer() { $hat = []; - $pings = json_decode(file_get_contents(WS_CACHE . '/farmpings')); + $pings = json_decode(file_get_contents('/home/extranet/toolbox/storage/fluidbookfarm/pings')); foreach (self::$_farmServers as $k => $farmServer) { if (!isset($pings[$k]) || !$pings[$k]) {