]> _ Git - cubeextranet.git/commitdiff
wait #6216 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 25 Aug 2023 12:02:24 +0000 (12:02 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 25 Aug 2023 12:02:24 +0000 (12:02 +0000)
.docker/config/cron/crontab
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Metier/class.ws.document.php

index 5113fbc0bd71bb2770591ef2d40079d7bd1aa933..22548a35daabe294d6f917f263c05477493e2146 100644 (file)
@@ -7,6 +7,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 0 5 * * *   root    /usr/bin/lynx --dump https://workshop.fluidbook.com/maintenance/cleanCompiledBooks >/dev/null 2>/dev/null
 40 * * * *  root    /usr/bin/lynx --dump https://workshop.fluidbook.com/maintenance/cleanPackages >/dev/null 2>/dev/null
 0 1 * * *   root    /usr/bin/lynx --dump https://workshop.fluidbook.com/maintenance/cleanConversionSessions >/dev/null 2>/dev/null
+* * * * *   root    /usr/bin/lynx --dump https://workshop.fluidbook.com/maintenance/pingFarm >/dev/null 2>/dev/null
 */5 * * * * root    /application/bin/fixpackagerrights >/dev/null 2>/dev/null
 35 3 * * *  root    /application/bin/compresslogs >/dev/null 2>/dev/null
 10 * * * *  root    /application/bin/cleantmp >/dev/null 2>/dev/null
index c8ca06a9e3769ecb0505cdfb81b7a44f8ed15f0d..736ddce841d7454c53e3eb14279b2f16df6ccad3 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+use hollodotme\FastCGI\Client;
+use hollodotme\FastCGI\Requests\PostRequest;
+
 class wsMaintenance
 {
 
@@ -1774,6 +1777,26 @@ class wsMaintenance
     {
         echo file_get_contents('https://toolbox.fluidbook.com/openmaintenance/updatesources');
     }
+
+    public function pingFarm()
+    {
+        $servers = json_decode(file_get_contents('/data/toolbox/storage/fluidbookfarm/servers'), true);
+        $res = [];
+        foreach ($servers as $server) {
+            set_time_limit(0);
+
+            try {
+                $response = trim((new Client())->sendRequest(wsDocument::getFCGIConnexion($server, 5), new PostRequest('ping.php', http_build_query([])))->getBody());
+                if ($response == '1') {
+                    $res[] = $server;
+                }
+            } catch (Exception $e) {
+
+            }
+        }
+        file_put_contents(WS_CACHE . '/farmservers', json_encode($res));
+
+    }
 }
 
 
index 606716afdb1edbc988eabaa62798da6c238c9ac3..84f138f9961fa45a21cdcbada421d3b9a04e7caf 100644 (file)
@@ -450,7 +450,7 @@ class wsDocument extends cubeMetier
     public static function getFarmServers()
     {
         if (null === self::$_farmServers) {
-            self::$_farmServers = json_decode(file_get_contents('/data/toolbox/storage/fluidbookfarm/servers'), true);
+            self::$_farmServers = json_decode(file_get_contents(WS_CACHE . '/farmservers'), true);
         }
 
         return self::$_farmServers;
@@ -459,16 +459,11 @@ class wsDocument extends cubeMetier
     public static function pickOneFarmServer($region = 'UE')
     {
         $hat = [];
-        $pings = json_decode(file_get_contents('/data/toolbox/storage/fluidbookfarm/servers'));
 
         $allServers = [];
         $regionServers = [];
 
         foreach (self::getFarmServers() as $k => $farmServer) {
-            if (!isset($pings[$k]) || !$pings[$k]) {
-                continue;
-            }
-
             $allServers[$k] = $farmServer['weight'];
             if ($region == $farmServer['region']) {
                 $regionServers[$k] = $farmServer['weight'];