- Timestamp:
- 2009-03-13T13:12:18+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/server/Server2.java
r18558 r18669 3 3 4 4 import java.io.File; 5 import java.io.FileInputStream; 6 import java.io.FileOutputStream; 7 import java.util.Properties; 8 9 import org.apache.log4j.*; 5 10 6 11 import org.greenstone.server.BaseServer; … … 9 14 public class Server2 extends BaseServer 10 15 { 11 16 protected String libraryURL; 17 12 18 public Server2(String gsdl2_home, String lang) 13 19 { 14 super(gsdl2_home,lang); 20 super(gsdl2_home, lang, 21 gsdl2_home+File.separator+"lib"+File.separator+"java"+File.separator+"build.properties"); 15 22 16 23 Property = new Server2Property(); … … 22 29 START_CMD = "web-start"; 23 30 RESTART_CMD = "web-restart"; 24 CONFIGURE_CMD = " web-configure";31 CONFIGURE_CMD = "configure-web"; 25 32 STOP_CMD = "web-stop"; 26 33 27 34 autoStart(); 28 35 } 36 37 // Prepare the log4j.properties for GS2 38 protected void initLogger() { 39 40 String libjavaFolder = gsdl_home+File.separator+"lib"+File.separator+"java"+File.separator; 41 File propsFile = new File(libjavaFolder+"log4j.properties"); 42 43 // create it from the template file log4j.properties.in 44 if(!propsFile.exists()) { 45 try { 46 // need to set gsdl2.home property's value to be gsdl_home, 47 // so that the location of the log files gets resolved correctly 48 49 // load the template log4j.properties.in file into logProps 50 FileInputStream infile = new FileInputStream(new File(libjavaFolder+"log4j.properties.in")); 51 if(infile != null) { 52 Properties logProps = new Properties(); 53 logProps.load(infile); 54 infile.close(); 55 56 // set gsdl3.home to gsdl_home 57 logProps.setProperty("gsdl2.home", gsdl_home); 58 59 // write the customised properties out to a custom log4j.properties file 60 FileOutputStream outfile = new FileOutputStream(propsFile); 61 if(outfile != null) { 62 logProps.store(outfile, "Customised log4j.properties file"); 63 outfile.close(); 64 } else { 65 System.err.println("Could not store properties file " + propsFile + " for Server2."); 66 } 67 } 68 } catch(Exception e) { 69 System.err.println("Exception occurred when custom-configuring the logger for Server2.\n" + e); 70 } 71 } 72 73 // now configure the logger with the custom log4j.properties file 74 if(propsFile.exists()) { 75 PropertyConfigurator.configure(propsFile.getAbsolutePath()); 76 } else { 77 System.err.println("Could not create properties file " + propsFile + " for Server2."); 78 } 79 } 80 29 81 30 82 protected int runTarget(String cmd) … … 36 88 } 37 89 90 public String getBrowserURL() { 91 return libraryURL; 92 } 93 94 // works out the library URL again 95 public void reload() { 96 // default values, to be replaced with what's in gsdlsite.cfg 97 String host = "localhost"; 98 String port = "8080"; 99 String gwcgi; 100 String httpprefix = "gsdl"; 101 String suffix = "/cgi-bin/library.cgi"; 102 103 // get the prefix from the gsdlsite.cfg and build.properties files 104 // (port number and servername) 105 try{ 106 File gsdlsite_cfg = new File(gsdl_home + File.separator + "cgi-bin" + File.separator + "gsdlsite.cfg"); 107 FileInputStream fin = new FileInputStream(gsdlsite_cfg); 108 Properties gsdlProperties = new Properties(); 109 if(fin != null) { 110 gsdlProperties.load(fin); 111 112 gwcgi = gsdlProperties.getProperty("gwcgi"); 113 if(gwcgi != null) { 114 suffix = gwcgi; 115 } else { 116 httpprefix = gsdlProperties.getProperty("httpprefix", httpprefix); 117 suffix = httpprefix + suffix; 118 } 119 fin.close(); 120 } else { 121 recordError("Could not open gsdlsite_cfg for reading, using default library prefix."); 122 } 123 reloadBuildProperties(); 124 host = build_properties.getProperty("apache.server", host); 125 port = build_properties.getProperty("apache.port", port); 126 127 } catch(Exception e) { 128 recordError("Exception trying to load properties from gsdlsite_cfg. Using default library prefix.", e); 129 suffix = httpprefix + suffix; 130 } 131 132 libraryURL = "http://" + host + ":" + port + suffix; 133 //recordSuccess("**** browser URL is: " + libraryURL); 134 135 } 136 38 137 39 138 public static void main (String[] args)
Note:
See TracChangeset
for help on using the changeset viewer.