int main(int argc, char *argv[]) { try { // Démarrer le crawler if(argc == 1) { logger.initialize(); database.connect(); Crawler crawler; crawler.start(); } // Effectuer une recherche else if(argc == 2) { logger.initialize("search"); database.connect(); Search::getResult(argv[1]); } } catch(exception& e) { logger.log(Logger::ALERT, e.what()); } return 0; }
/** * Implementation of run */ void Crawler::run(SharedQueue *sq,const char* dataDir) { while (true) { while ( (*sq).sharedQueue.empty() ) { sleep(1); // TODO } QueueNode qNode = (*sq).sharedQueue.front(); pthread_mutex_lock(&sq->lock); (*sq).sharedQueue.pop(); pthread_mutex_unlock(&sq->lock); Crawler newCrawler; newCrawler.addURLStart( qNode.urlstart ); if (qNode.count != -1) newCrawler.addCrawlerCount( qNode.count ); for(int i=0;i<qNode.dontcrawlnr;++i) newCrawler.dontCrawl( qNode.dontcrawl[i] ); newCrawler.addDataDirectory(dataDir); newCrawler.start(); } }