]> git.mxchange.org Git - friendica.git/commitdiff
Daily updating the server status
authorMichael <heluecht@pirati.ca>
Mon, 13 Mar 2017 22:16:09 +0000 (22:16 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 13 Mar 2017 22:16:09 +0000 (22:16 +0000)
include/cron.php
include/discover_poco.php

index 2fc8de51c5ebb25f61dde5820c67cc58ac6e9095..cf9b9fc6226ae57e88e6c075cc4c8dd9ac237980 100644 (file)
@@ -123,6 +123,8 @@ function cron_run(&$argv, &$argc){
 
                update_contact_birthdays();
 
+               proc_run(PRIORITY_LOW, "include/discover_poco.php", "update_server");
+
                proc_run(PRIORITY_LOW, "include/discover_poco.php", "suggestions");
 
                set_config('system','last_expire_day',$d2);
index 9a32790ea0b7ada986dbff896bb0424552b723cc..9de0303208fe40444d426d2f70dd76de584f47c5 100644 (file)
@@ -35,6 +35,7 @@ function discover_poco_run(&$argv, &$argc){
        - checkcontact: Updates gcontact entries
        - suggestions: Discover other servers for their contacts.
        - server <poco url>: Searches for the poco server list. "poco url" is base64 encoded.
+       - update_server: Frequently check the first 250 servers for vitality.
        */
 
        if(($argc > 2) && ($argv[1] == "dirsearch")) {
@@ -46,6 +47,8 @@ function discover_poco_run(&$argv, &$argc){
                $mode = 3;
        } elseif(($argc == 3) && ($argv[1] == "server")) {
                $mode = 4;
+       } elseif(($argc == 2) && ($argv[1] == "update_server")) {
+               $mode = 5;
        } elseif ($argc == 1) {
                $search = "";
                $mode = 0;
@@ -64,7 +67,9 @@ function discover_poco_run(&$argv, &$argc){
 
        logger('start '.$search);
 
-       if ($mode == 4) {
+       if ($mode == 5) {
+               update_server();
+       } elseif ($mode == 4) {
                $server_url = base64_decode($argv[2]);
                if ($server_url == "") {
                        return;
@@ -102,6 +107,34 @@ function discover_poco_run(&$argv, &$argc){
        return;
 }
 
+/**
+ * @brief Updates the first 250 servers
+ *
+ */
+function update_server() {
+       $r = q("SELECT `url`, `created`, `last_failure`, `last_contact` FROM `gserver` ORDER BY rand()");
+
+       if (!dbm::is_result($r)) {
+               return;
+       }
+
+       $updated = 0;
+
+       foreach ($r AS $server) {
+               if (!poco_do_update($server["created"], "", $server["last_failure"], $server["last_contact"])) {
+                       continue;
+               }
+echo $server["url"]."\n";
+               logger('Update server status for server '.$server["url"], LOGGER_DEBUG);
+
+               proc_run(PRIORITY_LOW, "include/discover_poco.php", "server", base64_encode($server["url"]));
+
+               if (++$updated > 250) {
+                       return;
+               }
+       }
+}
+
 function discover_users() {
        logger("Discover users", LOGGER_DEBUG);