aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2016-11-11 20:54:12 +0100
committerChristian Weiske <cweiske@cweiske.de>2016-11-11 20:54:12 +0100
commit08fc60226f224de87d665aa7c55b6eaa9f66d768 (patch)
tree2dee8eb122a167a84e9fcb1840cdc88eb012497c /src
parent696fcd7ce4d495e356667019493bf312e2a6e47b (diff)
downloadphinde-08fc60226f224de87d665aa7c55b6eaa9f66d768.tar.gz
phinde-08fc60226f224de87d665aa7c55b6eaa9f66d768.zip
status page
Diffstat (limited to 'src')
-rw-r--r--src/phinde/Elasticsearch.php10
-rw-r--r--src/phinde/Queue.php21
2 files changed, 30 insertions, 1 deletions
diff --git a/src/phinde/Elasticsearch.php b/src/phinde/Elasticsearch.php
index 9babfee..069cf1f 100644
--- a/src/phinde/Elasticsearch.php
+++ b/src/phinde/Elasticsearch.php
@@ -58,6 +58,16 @@ class Elasticsearch
$r->send();
}
+ public function countDocuments()
+ {
+ $r = new Elasticsearch_Request(
+ $this->baseUrl . 'document/_count',
+ \HTTP_Request2::METHOD_GET
+ );
+ $res = $r->send();
+ return json_decode($res->getBody())->count;
+ }
+
public function search($query, $filters, $site, $page, $perPage, $sort)
{
if (preg_match_all('#nick:([^ ]*)#', $query, $matches)) {
diff --git a/src/phinde/Queue.php b/src/phinde/Queue.php
index a58a257..1033d7a 100644
--- a/src/phinde/Queue.php
+++ b/src/phinde/Queue.php
@@ -9,6 +9,7 @@ class Queue
{
$this->gmclient = new \GearmanClient();
$this->gmclient->addServer('127.0.0.1');
+ $this->queueName = $GLOBALS['phinde']['queuePrefix'] . 'phinde_process';
}
public function addToProcessList($linkUrl, $actions)
@@ -19,7 +20,7 @@ class Queue
);
$this->gmclient->doBackground(
- $GLOBALS['phinde']['queuePrefix'] . 'phinde_process',
+ $this->queueName,
serialize(
array(
'url' => $linkUrl,
@@ -36,5 +37,23 @@ class Queue
exit(2);
}
}
+
+ public function getServerStatus()
+ {
+ $cmd = 'gearadmin --status'
+ . '| grep ' . escapeshellarg($this->queueName);
+ $line = exec($cmd);
+
+ $parts = preg_split('#\s+#', $line);
+ if (count($parts) !== 4) {
+ throw new \Exception('gearadmin status line does not have 4 parts');
+ }
+
+ return array(
+ 'tasks' => $parts[1],
+ 'processing' => $parts[2],
+ 'workers' => $parts[3],
+ );
+ }
}
?>