]> git.mxchange.org Git - friendica.git/blobdiff - include/poller.php
Merge remote branch 'upstream/master'
[friendica.git] / include / poller.php
index 0a0e66b865ec0445131a9301e1e064e3e16ff496..fefc9b381d4a6c18d74cdb20eff26b57aaa42a38 100644 (file)
@@ -30,6 +30,17 @@ function poller_run($argv, $argc){
        load_config('config');
        load_config('system');
 
+       $maxsysload = intval(get_config('system','maxloadavg'));
+       if($maxsysload < 1)
+               $maxsysload = 50;
+       if(function_exists('sys_getloadavg')) {
+               $load = sys_getloadavg();
+               if(intval($load[0]) > $maxsysload) {
+                       logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
+                       return;
+               }
+       }
+
        $lockpath = get_config('system','lockpath');
        if ($lockpath != '') {
                $pidfile = new pidfile($lockpath, 'poller.lck');
@@ -39,6 +50,8 @@ function poller_run($argv, $argc){
                }
        }
 
+
+
        $a->set_baseurl(get_config('system','url'));
 
        load_hooks();
@@ -113,7 +126,9 @@ function poller_run($argv, $argc){
                $force     = true;
        }
 
-       $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
+       $interval = intval(get_config('system','poll_interval'));
+       if(! $interval) 
+               $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
 
        $sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
 
@@ -186,8 +201,8 @@ function poller_run($argv, $argc){
 
 
                                if($contact['subhub']) {
-                                       $interval = get_config('system','pushpoll_frequency');
-                                       $contact['priority'] = (($interval !== false) ? intval($interval) : 3);
+                                       $poll_interval = get_config('system','pushpoll_frequency');
+                                       $contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
                                        $hub_update = false;
        
                                        if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force)