public static function updateFarm()
{
- foreach (wsDocument::getFarmServers() as $farmer) {
- echo '<h2>' . $farmer['host'] . '</h2><pre>';
+
+ 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();
}
}
+ public static function pingFarm()
+ {
+ $originalConnectionTimeout = ini_get('default_socket_timeout');
+ ini_set('default_socket_timeout', 5);
+ $pings = [];
+ foreach (wsDocument::getFarmServers() as $id => $farmer) {
+ echo '<h2>' . $farmer['host'] . ' (' . $id . ')</h2>';
+ $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(WS_CACHE . '/farmpings', json_encode($pings));
+ ini_set('default_socket_timeout', $originalConnectionTimeout);
+ }
+
public static function fluidbookFarm($args)
{
global $core;
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],
+ ['host' => 'paris.cubedesigners.com', 'port' => 22922, 'weight' => 2],
+ ['host' => 'paris.cubedesigners.com', 'port' => 22923, 'weight' => 1],
+ ['host' => 'godzilla.cubedesigners.com', 'weight' => 3],
+ ['host' => 'dracula.cubedesigners.com', 'weight' => 3],
+ ['host' => 'her.cubedesigners.com', 'weight' => 4],
];
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'));
+
foreach (self::$_farmServers as $k => $farmServer) {
+ if (!isset($pings[$k]) || !$pings[$k]) {
+ continue;
+ }
for ($i = 0; $i < $farmServer['weight']; $i++) {
$hat[] = $k;
}
public function _getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)
{
global $core;
- if ($core->user->utilisateur_id == 5) {
+
+ $farmTesters = [3, 5];
+ if (in_array($core->user->utilisateur_id, $farmTesters)) {
return $this->_getFileFarm($page, $format, $resolution, $withText, $withGraphics, $version, $force);
}