- Timestamp:
- 2011-08-23T20:28:57+12:00 (13 years ago)
- Location:
- main/trunk/greenstone3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/resources/java/server.properties
r24207 r24455 17 17 18 18 ServerSettings.Title=Server settings 19 ServerSettings.Auto_Start=Enter the library automatically 19 ServerSettings.Auto_Start=Enter the library automatically on startup 20 20 ServerSettings.Keep_Port=Do not modify port 21 21 ServerSettings.OK=OK -
main/trunk/greenstone3/src/java/org/greenstone/server/BaseServer.java
r22085 r24455 64 64 65 65 config_properties = new Properties(); 66 reloadConfigProperties( );66 reloadConfigProperties(true); // first time starting the server, work out port_number 67 67 68 68 dictionary = new Dictionary("server", lang, this.getClass().getClassLoader()); … … 250 250 } 251 251 252 public void reloadConfigProperties( ) {252 public void reloadConfigProperties(boolean port_has_changed) { 253 253 try { 254 254 FileInputStream in = new FileInputStream(config_properties_file); -
main/trunk/greenstone3/src/java/org/greenstone/server/BaseServerSettings.java
r24233 r24455 234 234 // save everything to config_properties if things have changed 235 235 boolean has_changed = false; 236 boolean require_restart = false; 236 boolean require_restart = false; 237 boolean port_has_changed = false; 237 238 238 239 if (portNum != ((Integer)portNumber_spinner.getValue()).intValue()) { 239 has_changed = true; 240 require_restart = true; 240 port_has_changed = true; 241 has_changed = true; 242 require_restart = true; 241 243 server.reconfigRequired(); 242 244 portNum = ((Integer)portNumber_spinner.getValue()).intValue(); … … 295 297 scriptReadWrite.writeOutFile(BaseServer.config_properties_file, newFileLines); 296 298 297 server.reloadConfigProperties( );299 server.reloadConfigProperties(port_has_changed); 298 300 server.reload(); // work out the URL again in case it has changed 299 301 if (require_restart){ -
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.