Allow worker instances of multiple projects in parallel
authorChristian Weiske <cweiske@cweiske.de>
Tue, 30 Aug 2016 11:10:03 +0000 (13:10 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 30 Aug 2016 11:10:03 +0000 (13:10 +0200)
Change "queuePrefix" configuration in each project

Resolves: #5

bin/phinde-worker.php
data/config.php.dist
src/phinde/Queue.php

index 7adb7af95aa584a188b010165ec453725f7149df..939db1f9a37691dbbd016072ce1608e23415860c 100755 (executable)
@@ -32,7 +32,7 @@ $gmworker->addServer('127.0.0.1');
 
 if (isset($queues['crawl'])) {
     $gmworker->addFunction(
-        'phinde_crawl',
+        $GLOBALS['phinde']['queuePrefix'] . 'phinde_crawl',
         function(\GearmanJob $job) {
             $data = unserialize($job->workload());
             echo "-- Crawling " . $data['url'] . "\n";
@@ -42,7 +42,7 @@ if (isset($queues['crawl'])) {
 }
 if (isset($queues['index'])) {
     $gmworker->addFunction(
-        'phinde_index',
+        $GLOBALS['phinde']['queuePrefix'] . 'phinde_index',
         function(\GearmanJob $job) {
             $data = unserialize($job->workload());
             echo "-- Indexing " . $data['url'] . "\n";
index dc1cff85131b3c524121e1c4607df2871851fe80..3c1ccea35f33e1910c01c6413ceaa5fb90bf20be 100644 (file)
@@ -19,5 +19,8 @@ $GLOBALS['phinde'] = array(
     //if directly linked URLs shall be indexed, even if they are
     // on a non-whitelisted domain
     'indexNonAllowed' => true,
+    //prefix for the gearman queue names, needed when multiple instances
+    //are running in parallel
+    'queuePrefix' => '',
 );
 ?>
\ No newline at end of file
index 98f6462cd90ccc7163c60605dbae106c2b17de18..406f27e550e521bdbad25a5c20aaa15fa38ab1fb 100644 (file)
@@ -15,7 +15,7 @@ class Queue
     {
         echo "Queuing for indexing: $linkUrl\n";
         $this->gmclient->doBackground(
-            'phinde_index',
+            $GLOBALS['phinde']['queuePrefix'] . 'phinde_index',
             serialize(
                 array(
                     'url'    => $linkUrl,
@@ -36,7 +36,7 @@ class Queue
     {
         echo "Queuing for crawling: $linkUrl\n";
         $this->gmclient->doBackground(
-            'phinde_crawl',
+            $GLOBALS['phinde']['queuePrefix'] . 'phinde_crawl',
             serialize(
                 array(
                     'url' => $linkUrl