}
- public static function updateFarm()
- {
-
- foreach (wsDocument::getFarmServers() as $id => $farmer) {
- echo '<h2>' . $farmer['host'] . ' (' . $id . ')</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 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 '<h2>' . $farmer['name'] . ' (' . $id . ')</h2>';
- if (isset($pings[$id]) && !$pings[$id]) {
- // If ping failed recently, we wait a bit before trying again.
- if (rand(0, 9) != 5) {
- echo '<p>Skipped, will try again soon</p>';
- 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 '<p>' . ($ok ? 'OK' : 'KO') . ' : ' . $cl->output . '</p>';
-
- $pings[$id] = $ok;
- }
- file_put_contents($cache, json_encode($pings));
- ini_set('default_socket_timeout', $originalConnectionTimeout);
- }
-
public static function fluidbookFarm($args)
{
global $core;
['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);
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]) {