Big patch merging crawling+indexing into one command, new json document structure
[phinde.git] / bin / phinde-worker.php
index e8253ff945c9e83f07686a50f84db0d4f9bef939..1e94535b1d5dc86f208a7113a5f6cbbe9c1a1cb6 100755 (executable)
@@ -4,24 +4,22 @@ namespace phinde;
 
 chdir(dirname($argv[0]));
 
+require_once __DIR__ . '/../src/init.php';
+
 $gmworker = new \GearmanWorker();
 $gmworker->addServer('127.0.0.1');
 
 $gmworker->addFunction(
-    'phinde_crawl',
-    function(\GearmanJob $job) {
-        $data = unserialize($job->workload());
-        echo "-- Crawling " . $data['url'] . "\n";
-        passthru('./crawl.php ' . escapeshellarg($data['url']));
-    }
-);
-$gmworker->addFunction(
-    'phinde_index',
+    $GLOBALS['phinde']['queuePrefix'] . 'phinde_process',
     function(\GearmanJob $job) {
         $data = unserialize($job->workload());
-        echo "-- Indexing " . $data['url'] . "\n";
-        passthru('./index.php ' . escapeshellarg($data['url']));
-        //exit();
+        echo "-- Processing " . $data['url']
+            . ' (' . implode(',', $data['actions']) . ')'
+            . "\n";
+        passthru(
+            './process.php ' . escapeshellarg($data['url'])
+            . ' ' . implode(' ', $data['actions'])
+        );
     }
 );