[ 
http://issues.apache.org/jira/browse/NUTCH-143?page=comments#action_12360689 ] 

Matt Kangas commented on NUTCH-143:
-----------------------------------

I'd like to see this fixed too. It would make error-checking in wrapper scripts 
much simpler to implement.

A fix would have to touch every .java file that has a main() method, because 
the problem is that the JVM returns status=0 from main(), because main() has a 
_void_ return type, after all.

To solve this, I recommend renaming all existing "main()" methods to "doMain()" 
and adding the following to each affected file:

  /**
   * main() wrapper that returns proper exit status
   */
  public static void main(String[] args) {
    Runtime rt = Runtime.getRuntime();
    try {
      boolean status = doMain(args);
      rt.exit(status ? 0 : 1);
    }
    catch (Exception e) {
      LOG.log(Level.SEVERE, LOGPREFIX + "error, caught Exception in main()", 
e);      
      rt.exit(1);
    }
  }


> Improper error numbers returned on exit
> ---------------------------------------
>
>          Key: NUTCH-143
>          URL: http://issues.apache.org/jira/browse/NUTCH-143
>      Project: Nutch
>         Type: Bug
>     Versions: 0.8-dev
>     Reporter: Rod Taylor

>
> Nutch does not obey standard command line error numbers which can make it 
> difficult to script around commands.
> Both of the below should have exited with an error number larger than 0 
> causing the shell script to enter into the 'Failed' case.
> bash-3.00$ /opt/nutch/bin/nutch updatedb && echo "==>Success" || echo 
> "==>Failed"
> Usage: <crawldb> <segment>
> ==>Success
> bash-3.00$ /opt/nutch/bin/nutch readdb && echo "==>Success" || echo 
> "==>Failed"
> Usage: CrawlDbReader <crawldb> (-stats | -dump <out_dir> | -url <url>)
>         <crawldb>       directory name where crawldb is located
>         -stats  print overall statistics to System.out
>         -dump <out_dir> dump the whole db to a text file in <out_dir>
>         -url <url>      print information on <url> to System.out
> ==>Success
> Note that the nutch shell script functions as expected:
> bash-3.00$ /opt/nutch/bin/nutch  && echo "==>Success" || echo "==>Failed"
> Usage: nutch COMMAND
> where COMMAND is one of:
>   crawl             one-step crawler for intranets
>   readdb            read / dump crawl db
>   readlinkdb        read / dump link db
>   admin             database administration, including creation
>   inject            inject new urls into the database
>   generate          generate new segments to fetch
>   fetch             fetch a segment's pages
>   parse             parse a segment's pages
>   updatedb          update crawl db from segments after fetching
>   invertlinks       create a linkdb from parsed segments
>   index             run the indexer on parsed segments and linkdb
>   merge             merge several segment indexes
>   dedup             remove duplicates from a set of segment indexes
>   server            run a search server
>   namenode          run the NDFS namenode
>   datanode          run an NDFS datanode
>   ndfs              run an NDFS admin client
>   jobtracker        run the MapReduce job Tracker node
>   tasktracker       run a MapReduce task Tracker node
>   job               manipulate MapReduce jobs
>  or
>   CLASSNAME         run the class named CLASSNAME
> Most commands print help when invoked w/o parameters.
> ==>Failed

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Nutch-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nutch-developers

Reply via email to