Changeset 19441

Show
Ignore:
Timestamp:
13.05.2009 14:56:16 (11 years ago)
Author:
ak19
Message:

Uses PortFinder?.isPortAvailable() with the new verbose flag and prints out a message saying which port is being used if this is different from what was specified in llssite.cfg.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/server/Server2.java

    r19428 r19441  
    211211    try { 
    212212        int portNum = Integer.parseInt(port); 
    213         boolean silent = true; 
    214         if(!PortFinder.isPortAvailable(portNum, silent)) { 
     213        boolean verbose = true; 
     214        if(!PortFinder.isPortAvailable(portNum, verbose)) { // first time, print any Port Unavailable messages 
    215215         
    216216        PortFinder portFinder = new PortFinder(portDefault, 101); 
    217         portNum = portFinder.findPortInRange(silent); 
    218         port = (portNum == -1) ? Integer.toString(portDefault) : Integer.toString(portNum); 
     217        // Search for a free port silently from now on--don't want more 
     218        // messages saying that a port could not be found... 
     219        portNum = portFinder.findPortInRange(!verbose); 
     220         
     221        if (portNum == -1) { 
     222            // If we've still not found a free port, do we try the default port again? 
     223            System.err.println("No free port found. Going to try on " + portDefault + " anyway."); 
     224            port = Integer.toString(portDefault); 
     225        } else { 
     226            port = Integer.toString(portNum); 
     227        } 
    219228        config_properties.setProperty("portnumber", port); // store the correct port 
    220229 
     
    226235 
    227236        configure_required_ = true; 
     237        System.err.println("Running server on port " + port + "."); 
    228238        }     
    229239    } catch (Exception e) {