Apache Nutch is an extensible and scalable web crawler
NUTCH-1883 bin/crawl: use function to run bin/nutch and check exit value
Sebastian Nagel09849b8a1737
diff --git a/CHANGES.txt b/CHANGES.txtindex 50d5e524c..3f6e4442b 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,7 +2,9 @@ Nutch Change LogNutch Current Development 1.10-SNAPSHOT-* NUTCH-NUTCH-1865 Enable use of SNAPSHOT's with Nutch Ivy dependency management (lewismc)+* NUTCH-1883 bin/crawl: use function to run bin/nutch and check exit value (snagel)++* NUTCH-1865 Enable use of SNAPSHOT's with Nutch Ivy dependency management (lewismc)* NUTCH-1882 ant eclipse target to add output path to src/test (snagel)diff --git a/src/bin/crawl b/src/bin/crawlindex 605602eca..2b6b57461 100644--- a/src/bin/crawl+++ b/src/bin/crawl@@ -97,13 +97,28 @@ if [ $mode = "distributed" ]; thenfifi-# initial injection-"$bin/nutch" inject "$CRAWL_PATH"/crawldb "$SEEDDIR"-RETCODE=$?-if [ $RETCODE -ne 0 ]- then exit $RETCODE-fi+function __bin_nutch {+ # run $bin/nutch, exit if exit value indicates error++ echo "$bin/nutch $@" ;# echo command and arguments+ "$bin/nutch" "$@"++ RETCODE=$?+ if [ $RETCODE -ne 0 ]+ then+ echo "Error running:"+ echo " $bin/nutch $@"+ echo "Failed with exit value $RETCODE."+ exit $RETCODE+ fi+}++++# initial injection+echo "Injecting seed URLs"+__bin_nutch inject "$CRAWL_PATH"/crawldb "$SEEDDIR"# main loop : rounds of generate - fetch - parse - update@@ -118,12 +133,7 @@ doecho `date` ": Iteration $a of $LIMIT"echo "Generating a new segment"- "$bin/nutch" generate $commonOptions "$CRAWL_PATH"/crawldb "$CRAWL_PATH"/segments -topN $sizeFetchlist -numFetchers $numSlaves -noFilter- RETCODE=$?-- if [ $RETCODE -ne 0 ]- then exit $RETCODE- fi+ __bin_nutch generate $commonOptions "$CRAWL_PATH"/crawldb "$CRAWL_PATH"/segments -topN $sizeFetchlist -numFetchers $numSlaves -noFilter# capture the name of the segment# call hadoop in distributed mode@@ -139,67 +149,33 @@ do# fetching the segmentecho "Fetching : $SEGMENT"- "$bin/nutch" fetch $commonOptions -D fetcher.timelimit.mins=$timeLimitFetch "$CRAWL_PATH"/segments/$SEGMENT -noParsing -threads $numThreads- RETCODE=$?-- if [ $RETCODE -ne 0 ]- then exit $RETCODE- fi+ __bin_nutch fetch $commonOptions -D fetcher.timelimit.mins=$timeLimitFetch "$CRAWL_PATH"/segments/$SEGMENT -noParsing -threads $numThreads# parsing the segmentecho "Parsing : $SEGMENT"# enable the skipping of records for the parsing so that a dodgy document# so that it does not fail the full taskskipRecordsOptions="-D mapred.skip.attempts.to.start.skipping=2 -D mapred.skip.map.max.skip.records=1"- "$bin/nutch" parse $commonOptions $skipRecordsOptions "$CRAWL_PATH"/segments/$SEGMENT- RETCODE=$?-- if [ $RETCODE -ne 0 ]- then exit $RETCODE- fi+ __bin_nutch parse $commonOptions $skipRecordsOptions "$CRAWL_PATH"/segments/$SEGMENT# updatedb with this segmentecho "CrawlDB update"- "$bin/nutch" updatedb $commonOptions "$CRAWL_PATH"/crawldb "$CRAWL_PATH"/segments/$SEGMENT- RETCODE=$?-- if [ $RETCODE -ne 0 ]- then exit $RETCODE- fi+ __bin_nutch updatedb $commonOptions "$CRAWL_PATH"/crawldb "$CRAWL_PATH"/segments/$SEGMENT# note that the link inversion - indexing routine can be done within the main loop# on a per segment basisecho "Link inversion"- "$bin/nutch" invertlinks "$CRAWL_PATH"/linkdb "$CRAWL_PATH"/segments/$SEGMENT- RETCODE=$?-- if [ $RETCODE -ne 0 ]- then exit $RETCODE- fi+ __bin_nutch invertlinks "$CRAWL_PATH"/linkdb "$CRAWL_PATH"/segments/$SEGMENTecho "Dedup on crawldb"$bin/nutch dedup $CRAWL_PATH/crawldb- RETCODE=$?-- if [ $RETCODE -ne 0 ]- then exit $RETCODE- fiif [ -n "$SOLRURL" ]; thenecho "Indexing $SEGMENT on SOLR index -> $SOLRURL"- "$bin/nutch" index -D solr.server.url=$SOLRURL "$CRAWL_PATH"/crawldb -linkdb "$CRAWL_PATH"/linkdb "$CRAWL_PATH"/segments/$SEGMENT- RETCODE=$?- if [ $RETCODE -ne 0 ]; then- exit $RETCODE- fi+ __bin_nutch index -D solr.server.url=$SOLRURL "$CRAWL_PATH"/crawldb -linkdb "$CRAWL_PATH"/linkdb "$CRAWL_PATH"/segments/$SEGMENTecho "Cleanup on SOLR index -> $SOLRURL"- "$bin/nutch" clean -D solr.server.url=$SOLRURL "$CRAWL_PATH"/crawldb- RETCODE=$?-- if [ $RETCODE -ne 0 ]; then- exit $RETCODE- fi+ __bin_nutch clean -D solr.server.url=$SOLRURL "$CRAWL_PATH"/crawldbelseecho "Skipping indexing: no SOLR url provided."fi@@ -209,39 +185,20 @@ do# and should be uncommented based on your requirements########################################################echo "Building WebGraph within $CRAWL_PATH on all segments in $CRAWL_PATH/segments/"- #"$bin/nutch" webgraph $commonOptions -filter -normalize -segmentDir "$CRAWL_PATH"/segments/ -webgraphdb "$CRAWL_PATH"-- #if [ $? -ne 0 ]- # then exit $?- #fi+ #__bin_nutch webgraph $commonOptions -filter -normalize -segmentDir "$CRAWL_PATH"/segments/ -webgraphdb "$CRAWL_PATH"#echo "Running Loops Job on WebGraph within $CRAWL_PATH"- #"$bin/nutch" org.apache.nutch.scoring.webgraph.Loops $commonOptions -webgraphdb "$CRAWL_PATH"-- #if [ $? -ne 0 ]- # then exit $?- #fi+ #__bin_nutch org.apache.nutch.scoring.webgraph.Loops $commonOptions -webgraphdb "$CRAWL_PATH"#echo "Running LinkRank Algorithm on WebGraph within $CRAWL_PATH"- #"$bin/nutch" linkrank $commonOptions -webgraphdb "$CRAWL_PATH"-- #if [ $? -ne 0 ]- # then exit $?- #fi+ #__bin_nutch linkrank $commonOptions -webgraphdb "$CRAWL_PATH"#echo "Running ScoreUpdater Job with $CRAWL_PATH/crawldb and WebGraph within $CRAWL_PATH"- #"$bin/nutch" scoreupdater $commonOptions -crawldb "$CRAWL_PATH"/crawldb -webgraphdb "$CRAWL_PATH"-- #if [ $? -ne 0 ]- # then exit $?- #fi+ #__bin_nutch scoreupdater $commonOptions -crawldb "$CRAWL_PATH"/crawldb -webgraphdb "$CRAWL_PATH"#echo "Running NodeDumper on WebGraph within $CRAWL_PATH and dumping output to $CRAWL_PATH/dump/scores"- #"$bin/nutch" nodedumper $commonOptions -scores -topn 1000 -webgraphdb "$CRAWL_PATH" -output "$CRAWL_PATH"/dump/scores+ #__bin_nutch nodedumper $commonOptions -scores -topn 1000 -webgraphdb "$CRAWL_PATH" -output "$CRAWL_PATH"/dump/scores- #if [ $? -ne 0 ]- # then exit $?- #fidoneexit 0