fix indexing, boost config
[phinde.git] / bin / phinde-worker.php
1 #!/usr/bin/env php
2 <?php
3 namespace phinde;
4
5 chdir(dirname($argv[0]));
6
7 $gmworker = new \GearmanWorker();
8 $gmworker->addServer('127.0.0.1');
9
10 $gmworker->addFunction(
11     'phinde_crawl',
12     function(\GearmanJob $job) {
13         $data = unserialize($job->workload());
14         echo "-- Crawling " . $data['url'] . "\n";
15         passthru('./crawl.php ' . escapeshellarg($data['url']));
16     }
17 );
18 $gmworker->addFunction(
19     'phinde_index',
20     function(\GearmanJob $job) {
21         $data = unserialize($job->workload());
22         echo "-- Indexing " . $data['url'] . "\n";
23         passthru('./index.php ' . escapeshellarg($data['url']));
24         //exit();
25     }
26 );
27
28 while ($gmworker->work()) {
29     if ($gmworker->returnCode() != GEARMAN_SUCCESS) {
30         echo 'Error running job: ' . $gmworker->returnCode() . "\n";
31         break;
32     }
33 }
34 ?>