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
<?php
+use hollodotme\FastCGI\Client;
+use hollodotme\FastCGI\Requests\PostRequest;
+
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));
+
+ }
}
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;
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'];