]> git.mxchange.org Git - friendica.git/commitdiff
Mute warnings in pidfile/Quit poller after an hour.
authorMichael Vogel <icarus@dabo.de>
Fri, 25 Sep 2015 15:38:56 +0000 (17:38 +0200)
committerMichael Vogel <icarus@dabo.de>
Fri, 25 Sep 2015 15:38:56 +0000 (17:38 +0200)
include/pidfile.php
include/poller.php

index 4f5b25ad756521af2dee7626a26beb6c83395964..3093e149aeb869acc2c35ca0a49e9087642e7cb6 100644 (file)
@@ -7,8 +7,8 @@ class pidfile {
                $this->_file = "$dir/$name.pid";
 
                if (file_exists($this->_file)) {
-                       $pid = trim(file_get_contents($this->_file));
-                       if (posix_kill($pid, 0)) {
+                       $pid = trim(@file_get_contents($this->_file));
+                       if (($pid != "") AND posix_kill($pid, 0)) {
                                $this->_running = true;
                        }
                }
@@ -21,7 +21,7 @@ class pidfile {
 
        public function __destruct() {
                if ((! $this->_running) && file_exists($this->_file)) {
-                       unlink($this->_file);
+                       @unlink($this->_file);
                }
        }
 
@@ -30,7 +30,7 @@ class pidfile {
        }
 
        public function running_time() {
-               return(time() - filectime($this->_file));
+               return(time() - @filectime($this->_file));
        }
 
        public function kill() {
index c919b9d2abffff4ef069f5e8d3bc439c461ac004..7255eaa6e0d57f9af72be61029cfd43b9c72aa2c 100644 (file)
@@ -66,6 +66,8 @@ function poller_run(&$argv, &$argc){
        if ($workers[0]["workers"] >= $queues)
                return;
 
+       $starttime = time();
+
        while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `created` LIMIT 1")) {
 
                if(function_exists('sys_getloadavg')) {
@@ -76,6 +78,10 @@ function poller_run(&$argv, &$argc){
                        }
                }
 
+               // Quit the poller once every hour
+               if (time() > ($starttime + 3600))
+                       return;
+
                q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = %d WHERE `id` = %d",
                        dbesc(datetime_convert()),
                        intval(getmypid()),