From e498bc6b7be64d99ce894d8fbcf9cb28eca1c395 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 10 Jan 2016 00:51:25 +0100 Subject: [PATCH] Control OpportunisticQM verbosity --- plugins/OpportunisticQM/OpportunisticQMPlugin.php | 2 ++ plugins/OpportunisticQM/lib/opportunisticqueuemanager.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/OpportunisticQM/OpportunisticQMPlugin.php b/plugins/OpportunisticQM/OpportunisticQMPlugin.php index 0b57fb4ccc..8e0486105f 100644 --- a/plugins/OpportunisticQM/OpportunisticQMPlugin.php +++ b/plugins/OpportunisticQM/OpportunisticQMPlugin.php @@ -4,6 +4,7 @@ class OpportunisticQMPlugin extends Plugin { public $qmkey = false; public $secs_per_action = 1; // total seconds to run script per action public $rel_to_pageload = true; // relative to pageload or queue start + public $verbosity = 1; public function onRouterInitialized($m) { @@ -26,6 +27,7 @@ class OpportunisticQMPlugin extends Plugin { 'qmkey' => common_config('opportunisticqm', 'qmkey'), 'max_execution_time' => $this->secs_per_action, 'started_at' => $this->rel_to_pageload ? $_startTime : null, + 'verbosity' => $this->verbosity, ); $qm = new OpportunisticQueueManager($args); $qm->runQueue(); diff --git a/plugins/OpportunisticQM/lib/opportunisticqueuemanager.php b/plugins/OpportunisticQM/lib/opportunisticqueuemanager.php index e993bc93d6..5c5ce4c203 100644 --- a/plugins/OpportunisticQM/lib/opportunisticqueuemanager.php +++ b/plugins/OpportunisticQM/lib/opportunisticqueuemanager.php @@ -24,6 +24,8 @@ class OpportunisticQueueManager extends DBQueueManager protected $started_at = null; protected $handled_items = 0; + protected $verbosity = null; + const MAXEXECTIME = 20; // typically just used for the /main/cron action, only used if php.ini max_execution_time is 0 public function __construct(array $args=array()) { @@ -116,7 +118,7 @@ class OpportunisticQueueManager extends DBQueueManager } if ($this->handled_items > 0) { common_debug('Opportunistic queue manager passed execution time/item handling limit without being out of work.'); - } else { + } elseif ($this->verbosity > 1) { common_debug('Opportunistic queue manager did not have time to start on this action (max: '.$this->max_execution_time.' exceeded: '.abs(time()-$this->started_at).').'); } return false; -- 2.39.5