/** * Starts the loop of a child-process. */ protected function startChildProcessLoop() { $this->initCrawlerProcess(); // Call overidable method initChildProcess() $this->initChildProcess(); // Start benchmark (if single-processed) if ($this->is_chlid_process == false) { PHPCrawlerBenchmark::start("crawling_process"); } // Init vars $stop_crawling = false; // Main-Loop while ($stop_crawling == false) { // Get next URL from cache $UrlDescriptor = $this->LinkCache->getNextUrl(); // die('startChildProcessLoop $UrlDescriptor'); // Process URL if ($UrlDescriptor != null) { $stop_crawling = $this->processUrl($UrlDescriptor); // die('startChildProcessLoop processUrl'); } else { // die('startChildProcessLoop sleep'); usleep(500000); } if ($this->multiprocess_mode != PHPCrawlerMultiProcessModes::MPMODE_PARENT_EXECUTES_USERCODE) { // If there's nothing more to do if ($this->LinkCache->containsURLs() == false) { $stop_crawling = true; $this->CrawlerStatusHandler->updateCrawlerStatus(null, PHPCrawlerAbortReasons::ABORTREASON_PASSEDTHROUGH); } // Check for abort form other processes if ($this->checkForAbort() !== null) { $stop_crawling = true; } } } // Loop enden gere. If child-process -> kill it if ($this->is_chlid_process == true) { // die('startChildProcessLoop KILL'); if ($this->multiprocess_mode == PHPCrawlerMultiProcessModes::MPMODE_PARENT_EXECUTES_USERCODE) { return; } else { exit; } } $this->crawlerStatus = $this->CrawlerStatusHandler->getCrawlerStatus(); // Cleanup crawler $this->cleanup(); // Stop benchmark (if single-processed) if ($this->is_chlid_process == false) { // die('startChildProcessLoop STOP'); PHPCrawlerBenchmark::stop("crawling_process"); } // die('startChildProcessLoop'); }