]> git.mxchange.org Git - friendica.git/commitdiff
Worker: New value for cooldown time after each function call
authorMichael Vogel <icarus@dabo.de>
Wed, 13 Jul 2016 17:43:16 +0000 (19:43 +0200)
committerMichael Vogel <icarus@dabo.de>
Wed, 13 Jul 2016 17:43:16 +0000 (19:43 +0200)
doc/htconfig.md
include/poller.php

index 2435da2baacfa3556e786161b99c0b5db6497967..f7266604f646d48bf51b907c7e033830f8f0f33c 100644 (file)
@@ -67,6 +67,7 @@ line to your .htconfig.php:
 * throttle_limit_week - Maximum number of posts that a user can send per week with the API.
 * throttle_limit_month - Maximum number of posts that a user can send per month with the API.
 * wall-to-wall_share (Boolean) - Displays forwarded posts like "wall-to-wall" posts.
+* worker_cooldown - Cooldown time after each worker function call. Default value is 0 seconds.
 * xrd_timeout - Timeout for fetching the XRD links. Default value is 20 seconds.
 
 ## service_class ##
index d134f30d0fac270001d5cac8d9e98bc1411d81d7..9ea0aac1b3419b46e0fecc422459d4caab1e3cc7 100644 (file)
@@ -10,6 +10,9 @@ if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
        chdir($directory);
 }
 
+use \Friendica\Core\Config;
+use \Friendica\Core\PConfig;
+
 require_once("boot.php");
 
 function poller_run(&$argv, &$argc){
@@ -58,6 +61,8 @@ function poller_run(&$argv, &$argc){
        if (poller_too_much_workers(2))
                return;
 
+       $cooldown = Config::get("system", "worker_cooldown", 0);
+
        $starttime = time();
 
        while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `created` LIMIT 1")) {
@@ -109,6 +114,11 @@ function poller_run(&$argv, &$argc){
                        logger("Process ".getmypid()." - ID ".$r[0]["id"].": ".$funcname." ".$r[0]["parameter"]);
                        $funcname($argv, $argc);
 
+                       if ($cooldown > 0) {
+                               logger("Process ".getmypid()." - ID ".$r[0]["id"].": ".$funcname." - in cooldown for ".$cooldown." seconds");
+                               sleep($cooldown);
+                       }
+
                        logger("Process ".getmypid()." - ID ".$r[0]["id"].": ".$funcname." - done");
 
                        q("DELETE FROM `workerqueue` WHERE `id` = %d", intval($r[0]["id"]));