- Timestamp:
- 2011-08-23T20:28:57+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/server/Server2.java
r24207 r24455 292 292 } 293 293 294 public void reloadConfigProperties( ) {295 super.reloadConfigProperties( );294 public void reloadConfigProperties(boolean port_has_changed) { 295 super.reloadConfigProperties(port_has_changed); 296 296 297 297 // make sure the port is okay, otherwise find another port 298 298 // first choice is port 80, second choice starts at 8282 299 299 String port = config_properties.getProperty("portnumber", "80"); 300 String keepport = config_properties.getProperty("keepport", "0"); // default is to not try to keep the same port300 String keepport = config_properties.getProperty("keepport", "0"); // default is to not try to force the same port if in use by other servers 301 301 302 302 int portDefault = 8282; 303 303 try { 304 int portNum = Integer.parseInt(port); 305 boolean verbose = true; 306 if(!PortFinder.isPortAvailable(portNum, verbose)) { // first time, print any Port Unavailable messages 304 int portNum = Integer.parseInt(port); 305 boolean verbose = true; 306 if(port_has_changed) { // this is the test that prevents the server from arbitrarily shifting the port. 307 // only check at configured port if it's not the current port (the port we 308 // are still running on), because that will always be in use and unavailable. 309 if(!PortFinder.isPortAvailable(portNum, verbose)) { // first time, print any Port Unavailable messages 307 310 if(keepport.equals("1")) { 308 311 String errorMsg = "Unable to run the Greenstone server on port " + port + ". It may already be in use."; … … 311 314 System.err.println("If you wish to try another port, go to File > Settings of the Greenstone Server interface and either change the port number or untick the \"Do Not Modify Port\" option there. Then press the \"Enter Library\" button."); 312 315 System.err.println("******************\n"); 313 } else { 314 316 } else { // can modify port, try to find a new port 317 315 318 PortFinder portFinder = new PortFinder(portDefault, 101); 316 319 // Search for a free port silently from now on--don't want more … … 336 339 System.err.println("Running server on port " + port + "."); 337 340 } 338 } 341 } 342 } 339 343 } catch (Exception e) { 340 344 recordError("Exception in Server2.reload(): " + e.getMessage());
Note:
See TracChangeset
for help on using the changeset viewer.