tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/startup StopTomcat.java
Date Tue, 27 Mar 2001 20:27:42 GMT
costin      01/03/27 12:27:42

  Modified:    src/share/org/apache/tomcat/startup StopTomcat.java
  Log:
  A quick fix for StopTomcat - if the file is not found ( probably because
  we run from a different machine or tomcat was rebuilt ) but
  command-line params are present ( port for example ), we'll execute
  instead of throwing exception.( and ignore that ajp12.id is not found )
  
  Revision  Changes    Path
  1.7       +33 -27    jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java
  
  Index: StopTomcat.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StopTomcat.java	2001/03/25 21:53:16	1.6
  +++ StopTomcat.java	2001/03/27 20:27:41	1.7
  @@ -81,6 +81,8 @@
       String host=null;
       int port=-1;
       String secret;
  +    // explicit command line params ( for port, host or secret )
  +    boolean commandLineParams=false;
       
       public StopTomcat() 
       {
  @@ -135,35 +137,36 @@
       void stopTomcat() throws Exception {
   	String tchome=getTomcatHome();
   
  -	if( secret==null ) {
  -	    try {
  -		BufferedReader rd=new BufferedReader
  -		    ( new FileReader( tchome + "/conf/ajp12.id"));
  -		String line=rd.readLine();
  -
  -		if( port < 0 ) {
  -		    try {
  -			port=Integer.parseInt( line );
  -		    } catch(NumberFormatException ex ) {
  -			ex.printStackTrace();
  -		    }
  +	// read TOMCAT_HOME/conf/ajp12.id unless command line params
  +	// specify a port/host/secret
  +	try {
  +	    BufferedReader rd=new BufferedReader
  +		( new FileReader( tchome + "/conf/ajp12.id"));
  +	    String line=rd.readLine();
  +	    
  +	    if( port < 0 ) {
  +		try {
  +		    port=Integer.parseInt( line );
  +		} catch(NumberFormatException ex ) {
  +		    ex.printStackTrace();
   		}
  -		
  -		line=rd.readLine();
  -		if( host==null ) host=line;
  -		line=rd.readLine();
  -		if( secret==null ) secret=line;
  -		if( "".equals( secret ) )
  -		    secret=null;
  -		
  -	    } catch( IOException ex ) {
  -		//ex.printStackTrace();
  -		System.out.println("Can't read " + tchome + "/conf/ajp12.id");
  -		System.out.println(ex.toString());
  -		return;
   	    }
  +	    
  +	    line=rd.readLine();
  +	    if( host==null ) host=line;
  +	    line=rd.readLine();
  +	    if( secret==null ) secret=line;
  +	} catch( IOException ex ) {
  +	    //ex.printStackTrace();
  +	    System.out.println("Can't read " + tchome + "/conf/ajp12.id");
  +	    //	    System.out.println(ex.toString());
  +	    if( ! commandLineParams )
  +		return;
   	}
  -	
  +
  +	if( "".equals( secret ) )
  +	    secret=null;
  +		
   	System.out.println("Stoping tomcat on " + host + ":" +port +" "
   			   + secret);
   	InetAddress address=null;
  @@ -257,6 +260,7 @@
   	    }
   	    if (arg.equals("-host") ) {
   		i++;
  +		commandLineParams=true;
   		if (i < args.length)
   		    host=args[i];
   		else
  @@ -264,6 +268,7 @@
   	    }
   	    if (arg.equals("-port") ) {
   		i++;
  +		commandLineParams=true;
   		if (i < args.length)
   		    port=Integer.parseInt( args[i] );
   		else
  @@ -271,7 +276,8 @@
   	    }
   	    if (arg.equals("-pass") ) {
   		i++;
  -		if (i < args.length)
  +		commandLineParams=true;
  +		if (i < args.length) 
   		    secret=args[i];
   		else
   		    return false;
  
  
  

Mime
View raw message