protected boolean configureURL(ApacheBinaryInfo binary, ConfigResponse config) { String port = null, address = null; if (binary.conf != null) { // XXX config parsing not complete Map cfg = ApacheBinaryInfo.parseConfig(binary.conf); String listen = (String) cfg.get("Listen"); if (listen != null) { int ix = listen.lastIndexOf(':'); if (ix == -1) { port = listen; address = (String) cfg.get("ServerName"); if (address != null) { ix = address.indexOf(':'); if (ix != -1) { address = address.substring(0, ix); } } } else { address = listen.substring(0, ix); port = listen.substring(ix + 1); } } setConfigTrack(config, binary.conf); String root = (String) cfg.get("ServerRoot"); if (root != null) { binary.root = root; } String log = (String) cfg.get("ErrorLog"); if (binary.serverRootRelative(log).exists()) { setLogTrack(config, log); } String pid = (String) cfg.get("PidFile"); if (pid != null) { File pidFile = binary.serverRootRelative(pid); if (pidFile.exists()) { setPidFile(config, pidFile.getPath()); } } } if (port == null) { port = getConfigProperty(Collector.PROP_PORT, "80"); } if (address == null) { address = getListenAddress(port, this.defaultIp); } config.setValue(Collector.PROP_PROTOCOL, getConnectionProtocol(port)); config.setValue(Collector.PROP_SSL, isSSL(port)); config.setValue(Collector.PROP_HOSTNAME, address); config.setValue(Collector.PROP_PORT, port); config.setValue(Collector.PROP_PATH, getConfigProperty(Collector.PROP_PATH, "/server-status")); return true; }
private void getServerInfo(ApacheBinaryInfo info, String[] args) { final String nameProp = "-Dhq.name="; String root = null; for (int i = 1; i < args.length; i++) { String arg = args[i]; if (arg.startsWith("-d")) { root = arg.substring(2, arg.length()); if (root.length() == 0) { root = args[i + 1]; } } else if (arg.startsWith("-f")) { info.conf = arg.substring(2, arg.length()); if (info.conf.length() == 0) { info.conf = args[i + 1]; } } else if (arg.startsWith(nameProp)) { info.name = arg.substring(nameProp.length(), arg.length()); } } if (root != null) { // -d overrides compiled in HTTPD_ROOT info.root = root; } if (info.conf != null) { // check that httpd.conf exists and is absolute File conf = new File(info.conf); if (!conf.isAbsolute() && (info.root != null)) { conf = new File(info.root, info.conf); } if (!conf.exists()) { info.conf = null; // use the defaults } } else { for (String conf : defaultConfs) { File cf = new File(info.root, conf); if (cf.exists() && cf.isFile()) { info.conf = cf.getAbsolutePath(); } } } log.debug( "[getServerInfo] info.conf=" + info.conf + ", info.root=" + info.root + ", info.name=" + info.name); }