this.daemonPort = port;
}
public void startCrawling() {
// start up the web server
WebServer server = new WebServer(this.daemonPort);
server.addHandler("crawldaemon", this);
server.start();
LOG.log(Level.INFO, "Crawl Daemon started by "
+ System.getProperty("user.name", "unknown"));
while (running) {
// okay, time to crawl
long timeBefore = System.currentTimeMillis();
crawler.crawl();
long timeAfter = System.currentTimeMillis();
milisCrawling += (timeAfter - timeBefore);
numCrawls++;
LOG.log(Level.INFO, "Sleeping for: [" + waitInterval + "] seconds");
// take a nap
try {
Thread.currentThread().sleep(waitInterval * 1000);
} catch (InterruptedException ignore) {
}
}
LOG.log(Level.INFO, "Crawl Daemon: Shutting down gracefully");
LOG.log(Level.INFO, "Num Crawls: [" + this.numCrawls + "]");
LOG.log(Level.INFO, "Total time spent crawling: ["
+ (this.milisCrawling / 1000.0) + "] seconds");
LOG.log(Level.INFO, "Average Crawl Time: ["
+ (this.getAverageCrawlTime() / 1000.0) + "] seconds");
server.shutdown();
}