diff options
author | Greg Wilkins | 2013-08-27 23:30:03 +0000 |
---|---|---|
committer | Greg Wilkins | 2013-08-27 23:30:03 +0000 |
commit | d66778ad0650ba9071ee99a76bc3182828d1ae0c (patch) | |
tree | 467727e709266743a403882b9070b25839964447 | |
parent | 7d308bf8a5462b359ffc6af5e09a2fe7981ad0c7 (diff) | |
download | org.eclipse.jetty.project-d66778ad0650ba9071ee99a76bc3182828d1ae0c.tar.gz org.eclipse.jetty.project-d66778ad0650ba9071ee99a76bc3182828d1ae0c.tar.xz org.eclipse.jetty.project-d66778ad0650ba9071ee99a76bc3182828d1ae0c.zip |
415826 start.jar module --enable and --disable
morphed mechanism into --initialize based templates
18 files changed, 166 insertions, 239 deletions
diff --git a/jetty-distribution/src/main/resources/modules/setuid.mod b/jetty-distribution/src/main/resources/modules/setuid.mod new file mode 100644 index 0000000000..f939eb17a9 --- /dev/null +++ b/jetty-distribution/src/main/resources/modules/setuid.mod @@ -0,0 +1,9 @@ +DEPEND=server +LIB=jetty-setuid-java-1.0.1.jar + +etc/jetty-setuid.xml + +INI=# jetty.startServerAsPrivileged=false +INI=# jetty.username=jetty +INI=# jetty.groupname=jetty +INI=# jetty.umask=002 diff --git a/jetty-distribution/src/main/resources/start.ini b/jetty-distribution/src/main/resources/start.ini index 94f1ac626a..70f94401fc 100644 --- a/jetty-distribution/src/main/resources/start.ini +++ b/jetty-distribution/src/main/resources/start.ini @@ -31,122 +31,10 @@ #=========================================================== -#=========================================================== -# Configure JVM arguments. -# If JVM args are include in an ini file then --exec is needed -# to start a new JVM from start.jar with the extra args. -# If you wish to avoid an extra JVM running, place JVM args -# on the normal command line and do not use --exec -#----------------------------------------------------------- -# --exec -# -Xmx2000m -# -Xmn512m -# -XX:+UseConcMarkSweepGC -# -XX:ParallelCMSThreads=2 -# -XX:+CMSClassUnloadingEnabled -# -XX:+UseCMSCompactAtFullCollection -# -XX:CMSInitiatingOccupancyFraction=80 -# -verbose:gc -# -XX:+PrintGCDateStamps -# -XX:+PrintGCTimeStamps -# -XX:+PrintGCDetails -# -XX:+PrintTenuringDistribution -# -XX:+PrintCommandLineFlags -# -XX:+DisableExplicitGC -# -Dorg.apache.jasper.compiler.disablejsr199=true - -#=========================================================== -# Default Server Options -# Use the core server jars with websocket on the classpath -# Add the contents of the resources directory to the classpath -# Add jars discovered in lib/ext to the classpath -# Include the core jetty configuration file -#----------------------------------------------------------- -threads.min=10 -threads.max=200 -threads.timeout=60000 -#jetty.host=myhost.com -jetty.dump.start=false -jetty.dump.stop=false - -#=========================================================== -# JMX Management -# To enable remote JMX access uncomment jmxremote and -# enable --exec -#----------------------------------------------------------- -# jetty.jmxrmihost=localhost -# jetty.jmxrmiport=1099 -# -Dcom.sun.management.jmxremote - -#=========================================================== -# Request logger -# Will add a handler to log all HTTP requests to a standard -# request log format file. -#----------------------------------------------------------- -# requestlog.retain=90 -# requestlog.append=true -# requestlog.extended=true - - -#=========================================================== -# stderr/stdout logging. -# The following configuration will redirect stderr and stdout -# to file which is rolled over daily. -#----------------------------------------------------------- -# jetty.log.retain=90 -#=========================================================== -# Enable SetUID -# The default user and group is 'jetty' and if you are -# starting as root you must change the run privledged to true -#----------------------------------------------------------- -# jetty.startServerAsPrivileged=false -# jetty.username=jetty -# jetty.groupname=jetty -# jetty.umask=002 -#=========================================================== -# HTTP Connector -#----------------------------------------------------------- -jetty.port=8080 -http.timeout=30000 -#=========================================================== -# SSL Context -# Create the keystore and trust store for use by -# HTTPS and SPDY -#----------------------------------------------------------- -# jetty.keystore=etc/keystore -# jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 -# jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g -# jetty.truststore=etc/keystore -# jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 -# jetty.secure.port=8443 -#=========================================================== -# HTTPS Connector -#----------------------------------------------------------- -# jetty.https.port=8443 - -#=========================================================== -# SPDY Connector -#----------------------------------------------------------- -# jetty.spdy.port=8443 - -# =========================================================== -# JAAS -# ----------------------------------------------------------- -# jaas.login.conf=etc/login.conf - -#=========================================================== -# Low resource managment -#----------------------------------------------------------- -# lowresources.period=1050 -# lowresources.lowResourcesIdleTimeout=200 -# lowresources.monitorThreads=true -# lowresources.maxConnections=0 -# lowresources.maxMemory=0 -# lowresources.maxLowResourcesTime=5000 diff --git a/jetty-jaas/src/main/config/modules/jaas.mod b/jetty-jaas/src/main/config/modules/jaas.mod index 2a608c7487..8fdba5ada4 100644 --- a/jetty-jaas/src/main/config/modules/jaas.mod +++ b/jetty-jaas/src/main/config/modules/jaas.mod @@ -9,3 +9,5 @@ LIB=lib/jetty-jaas-${jetty.version}.jar # JAAS configuration etc/jetty-jaas.xml + +INI=jaas.login.conf=etc/login.conf
\ No newline at end of file diff --git a/jetty-jmx/src/main/config/modules/jmx.mod b/jetty-jmx/src/main/config/modules/jmx.mod index 2a7922690e..11224a299c 100644 --- a/jetty-jmx/src/main/config/modules/jmx.mod +++ b/jetty-jmx/src/main/config/modules/jmx.mod @@ -7,3 +7,7 @@ LIB=lib/jetty-jmx-${jetty.version}.jar # JMX configuration etc/jetty-jmx.xml + +INI=# jetty.jmxrmihost=localhost +INI=# jetty.jmxrmiport=1099 +INI=# -Dcom.sun.management.jmxremote
\ No newline at end of file diff --git a/jetty-server/src/main/config/etc/jetty-ipaccess.xml b/jetty-server/src/main/config/etc/jetty-ipaccess.xml index deef173687..85f6b9c684 100644 --- a/jetty-server/src/main/config/etc/jetty-ipaccess.xml +++ b/jetty-server/src/main/config/etc/jetty-ipaccess.xml @@ -15,17 +15,16 @@ <Set name="handler"><Ref refid="oldhandler"/></Set> <Set name="white"> <Array type="String"> - <Item>127.0.0.1</Item> - <Item>127.0.0.2/*.html</Item> - </Array> + <Item>127.0.0.1</Item> + <Item>127.0.0.2/*.html</Item> + </Array> </Set> <Set name="black"> <Array type="String"> - <Item>127.0.0.1/blacklisted</Item> - <Item>127.0.0.2/black.html</Item> - </Array> + <Item>127.0.0.1/blacklisted</Item> + <Item>127.0.0.2/black.html</Item> + </Array> </Set> </New> </Set> - </Configure> diff --git a/jetty-server/src/main/config/modules/http.mod b/jetty-server/src/main/config/modules/http.mod index 94eed962e9..e1feadcaab 100644 --- a/jetty-server/src/main/config/modules/http.mod +++ b/jetty-server/src/main/config/modules/http.mod @@ -1,7 +1,10 @@ # -# Jetty HTTP Server +# Jetty HTTP Connector # DEPEND=server etc/jetty-http.xml + +INI=jetty.port=8080 +INI=http.timeout=30000
\ No newline at end of file diff --git a/jetty-server/src/main/config/modules/https.mod b/jetty-server/src/main/config/modules/https.mod index 5e930e934f..3b087d3ef9 100644 --- a/jetty-server/src/main/config/modules/https.mod +++ b/jetty-server/src/main/config/modules/https.mod @@ -1,8 +1,9 @@ # -# Jetty HTTP Server +# Jetty HTTPS Connector # -DEPEND=server +DEPEND=ssl -etc/jetty-ssl.xml etc/jetty-https.xml + +INI=# jetty.https.port=8443
\ No newline at end of file diff --git a/jetty-server/src/main/config/modules/jvm.mod b/jetty-server/src/main/config/modules/jvm.mod new file mode 100644 index 0000000000..cfec783974 --- /dev/null +++ b/jetty-server/src/main/config/modules/jvm.mod @@ -0,0 +1,24 @@ + +INI=#=========================================================== +INI=# Configure JVM arguments. +INI=# If JVM args are include in an ini file then --exec is needed +INI=# to start a new JVM from start.jar with the extra args. +INI=# If you wish to avoid an extra JVM running, place JVM args +INI=# on the normal command line and do not use --exec +INI=#----------------------------------------------------------- +INI=# --exec +INI=# -Xmx2000m +INI=# -Xmn512m +INI=# -XX:+UseConcMarkSweepGC +INI=# -XX:ParallelCMSThreads=2 +INI=# -XX:+CMSClassUnloadingEnabled +INI=# -XX:+UseCMSCompactAtFullCollection +INI=# -XX:CMSInitiatingOccupancyFraction=80 +INI=# -verbose:gc +INI=# -XX:+PrintGCDateStamps +INI=# -XX:+PrintGCTimeStamps +INI=# -XX:+PrintGCDetails +INI=# -XX:+PrintTenuringDistribution +INI=# -XX:+PrintCommandLineFlags +INI=# -XX:+DisableExplicitGC +INI=# -Dorg.apache.jasper.compiler.disablejsr199=true
\ No newline at end of file diff --git a/jetty-server/src/main/config/modules/lowresources.mod b/jetty-server/src/main/config/modules/lowresources.mod index 578d8165ed..101f638f40 100644 --- a/jetty-server/src/main/config/modules/lowresources.mod +++ b/jetty-server/src/main/config/modules/lowresources.mod @@ -5,3 +5,10 @@ DEPEND=server etc/jetty-lowresources.xml + +INI=# lowresources.period=1050 +INI=# lowresources.lowResourcesIdleTimeout=200 +INI=# lowresources.monitorThreads=true +INI=# lowresources.maxConnections=0 +INI=# lowresources.maxMemory=0 +INI=# lowresources.maxLowResourcesTime=5000
\ No newline at end of file diff --git a/jetty-server/src/main/config/modules/requestlog.mod b/jetty-server/src/main/config/modules/requestlog.mod index 060ca9f0a2..03c726c4ae 100644 --- a/jetty-server/src/main/config/modules/requestlog.mod +++ b/jetty-server/src/main/config/modules/requestlog.mod @@ -5,3 +5,7 @@ DEPEND=server etc/jetty-requestlog.xml + +INI=# requestlog.retain=90 +INI=# requestlog.append=true +INI=# requestlog.extended=true diff --git a/jetty-server/src/main/config/modules/server.mod b/jetty-server/src/main/config/modules/server.mod index aa6cad6b0e..ea6321a6f6 100644 --- a/jetty-server/src/main/config/modules/server.mod +++ b/jetty-server/src/main/config/modules/server.mod @@ -4,6 +4,7 @@ DEPEND=base DEPEND=xml +OPTIONAL=jvm LIB=lib/servlet-api-3.1.jar LIB=lib/jetty-schemas-3.1.jar @@ -13,3 +14,10 @@ LIB=lib/jetty-server-${jetty.version}.jar # Annotations needs annotations configuration etc/jetty.xml + +INI=threads.min=10 +INI=threads.max=200 +INI=threads.timeout=60000 +INI=#jetty.host=myhost.com +INI=jetty.dump.start=false +INI=jetty.dump.stop=false
\ No newline at end of file diff --git a/jetty-server/src/main/config/modules/ssl.mod b/jetty-server/src/main/config/modules/ssl.mod new file mode 100644 index 0000000000..2bfc167e93 --- /dev/null +++ b/jetty-server/src/main/config/modules/ssl.mod @@ -0,0 +1,12 @@ + +# SSL Keystore module + +DEPEND=server +etc/jetty-ssl.xml + +INI=jetty.keystore=etc/keystore +INI=jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 +INI=jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g +INI=jetty.truststore=etc/keystore +INI=jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 +INI=jetty.secure.port=8443 diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index e8d7806dd6..e2891a9621 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -28,6 +28,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.LineNumberReader; import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.ConnectException; @@ -41,6 +43,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.regex.Pattern; import org.eclipse.jetty.start.StartArgs.DownloadArg; @@ -505,14 +508,10 @@ public class Main } } - // Enables/Disable - for (String module : args.getDisable()) - { - disable(args,module,true); - } - for (String module : args.getEnable()) + // Initialize + for (String module : args.getInitialize()) { - enable(args,module,true); + initialize(args,module,true); } // Informational command line, don't run jetty @@ -635,100 +634,59 @@ public class Main } } - private void enable(StartArgs args, String name, boolean verbose) throws IOException + private void initialize(StartArgs args, String name, boolean topLevel) throws IOException { File start_d=baseHome.getFile("start.d"); - File ini=new File(start_d,name+".ini"); - - // Is it already enabled - if (ini.exists()) + + // Is this a module? + Module module=args.getAllModules().get(name); + if (module==null) { - if (verbose) - StartLog.warn("Module %s already enabled by: %s",name,baseHome.toShortForm(ini)); + StartLog.warn("ERROR: No known module for %s",name); return; } - - // Is there a disabled ini? - File disabled=new File(start_d,name+".ini.disabled"); - boolean copy=false; - if (!disabled.exists() && baseHome.isBaseDifferent()) - { - copy=true; - disabled=new File(new File(baseHome.getHomeDir(),"start.d"),name+".ini.disabled"); - if (!disabled.exists()) - disabled=new File(new File(baseHome.getHomeDir(),"start.d"),name+".ini"); - } - - if (disabled.exists()) - { - // enable module by renaming/copying ini template - System.err.printf("Enabling %s in %s from %s%n",name,baseHome.toShortForm(ini),baseHome.toShortForm(disabled)); - if (copy) - Files.copy(disabled.toPath(),ini.toPath()); - else - disabled.renameTo(ini); - args.parse(baseHome, new StartIni(ini)); - } - else if (args.getAllModules().resolveEnabled().contains(args.getAllModules().get(name))) + + // Is it already enabled + File ini=new File(start_d,name+".ini"); + if (ini.exists()) { - // No ini template and module is already enabled - List<String> sources=args.getSources(name); - if (sources!=null && sources.size()>0) - for (String s: args.getSources(name)) - StartLog.warn("Module %s is enabled in %s",name,s); + if (new StartIni(ini).getLineMatches(Pattern.compile("--module=(.*, *)*"+name)).size()==0) + StartLog.warn("ERROR: %s not initialised in %s!",name,baseHome.toShortForm(ini)); else - StartLog.warn("Module %s is already enabled (see --list-modules)",name); - + StartLog.warn("%-15s initialised in %s",name,baseHome.toShortForm(ini)); + return; } - else if (ini.createNewFile()) + else { - System.err.printf("Enabling %s in %s%n",name,baseHome.toShortForm(ini)); - // Create an ini - try(FileOutputStream out = new FileOutputStream(ini);) + // Should we create an ini file? + if (topLevel || module.getInitialise().size()>0) { - out.write(("--module="+name+"\n").getBytes("ISO-8859-1")); + if (ini.createNewFile()) + { + StartLog.warn("%-15s initialised in %s (created)",name,baseHome.toShortForm(ini)); + + // Create an ini + try(PrintWriter out = new PrintWriter(ini)) + { + out.println("# Initialize module "+name); + out.println("--module="+name); + for (String line : module.getInitialise()) + out.println(line); + } + args.parse(baseHome, new StartIni(ini)); + } + else + { + StartLog.warn("ERROR: %s cannot be initialised in %s! ",name,baseHome.toShortForm(ini)); + return; + } } - args.parse(baseHome, new StartIni(ini)); } - else - { - StartLog.warn("ERROR: Module %s cannot be enabled! ",name); - return; - } - + // Process dependencies - Modules modules = args.getAllModules(); - Module module=modules.get(name); if (module!=null) for (String parent:module.getParentNames()) - enable(args,parent,false); - } - - private void disable(StartArgs args, String name, boolean verbose) throws IOException - { - File start_d=baseHome.getFile("start.d"); - File ini=new File(start_d,name+".ini"); - - // Is it enabled? - if (ini.exists()) - { - File disabled=new File(start_d,name+".ini.disabled"); - - if (disabled.exists()) - { - StartLog.warn("ERROR: Disabled ini already exists: %s",baseHome.toShortForm(disabled)); - return; - } - - StartLog.warn("Disabling %s from %s",name,baseHome.toShortForm(ini)); - ini.renameTo(disabled); - - return; - } - - if (verbose) - StartLog.warn("Module %s, ini file already disabled: %s",name,baseHome.toShortForm(ini)); - + initialize(args,parent,false); } public void usage(boolean exit) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java index baf7d0e74a..99c6de4457 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java @@ -73,6 +73,8 @@ public class Module extends TextFile /** The name of this Module */ private String name; + /** The depth of the module in the tree */ + private int depth = 0; /** List of Modules, by name, that this Module depends on */ private Set<String> parentNames; /** List of Modules, by name, that this Module optionally depend on */ @@ -81,10 +83,10 @@ public class Module extends TextFile private Set<Module> parentEdges; /** The Edges to child modules */ private Set<Module> childEdges; - /** The depth of the module in the tree */ - private int depth = 0; /** List of xml configurations for this Module */ private List<String> xmls; + /** List of ini template lines */ + private List<String> initialise; /** List of library options for this Module */ private List<String> libs; /** List of downloads for this Module */ @@ -197,6 +199,11 @@ public class Module extends TextFile { return xmls; } + + public List<String> getInitialise() + { + return initialise; + } public List<String> getDownloads() { @@ -225,14 +232,15 @@ public class Module extends TextFile // Strip .ini this.name = Pattern.compile(".mod$",Pattern.CASE_INSENSITIVE).matcher(name).replaceFirst(""); - this.parentNames = new HashSet<>(); - this.optionalParentNames = new HashSet<>(); - this.parentEdges = new HashSet<>(); - this.childEdges = new HashSet<>(); - this.xmls = new ArrayList<>(); - this.libs = new ArrayList<>(); - this.downloads = new ArrayList<>(); - this.bootlibs = new ArrayList<>(); + parentNames=new HashSet<>(); + optionalParentNames=new HashSet<>(); + parentEdges=new HashSet<>(); + childEdges=new HashSet<>(); + xmls=new ArrayList<>(); + initialise=new ArrayList<>(); + libs=new ArrayList<>(); + downloads=new ArrayList<>(); + bootlibs=new ArrayList<>(); } public boolean isEnabled() @@ -279,6 +287,10 @@ public class Module extends TextFile bootlibs.add(value); handled = true; break; + case "INI": + initialise.add(value); + handled = true; + break; } } diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java index 1020ca78d0..1a36c1ce29 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java @@ -146,8 +146,7 @@ public class StartArgs private Properties properties = new Properties(); private Set<String> systemPropertyKeys = new HashSet<>(); private List<String> jvmArgs = new ArrayList<>(); - private List<String> enable = new ArrayList<>(); - private List<String> disable = new ArrayList<>(); + private List<String> initialize = new ArrayList<>(); private List<String> modulePersistEnable = new ArrayList<>(); private List<String> modulePersistDisable = new ArrayList<>(); private Modules allModules; @@ -455,14 +454,9 @@ public class StartArgs return this.commandLine; } - public List<String> getEnable() + public List<String> getInitialize() { - return enable; - } - - public List<String> getDisable() - { - return disable; + return initialize; } public List<DownloadArg> getDownloads() @@ -765,20 +759,11 @@ public class StartArgs return; } - if (arg.startsWith("--enable=")) - { - if (!CMD_LINE_SOURCE.equals(source)) - throw new UsageException(ERR_BAD_ARG,"%s not allowed in %s",arg,source); - enable.addAll(getValues(arg)); - run = false; - return; - } - - if (arg.startsWith("--disable=")) + if (arg.startsWith("--initialize=") || arg.startsWith("--initialise=") || arg.startsWith("--ini=")) { if (!CMD_LINE_SOURCE.equals(source)) throw new UsageException(ERR_BAD_ARG,"%s not allowed in %s",arg,source); - disable.addAll(getValues(arg)); + initialize.addAll(getValues(arg)); run = false; return; } diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java b/jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java index d14fb23294..4da2951a3b 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java @@ -67,6 +67,7 @@ public class TextFile implements Iterable<String> continue; } + // TODO - bad form calling derived method from base class constructor process(line.trim()); } } diff --git a/jetty-util/src/main/config/modules/logging.mod b/jetty-util/src/main/config/modules/logging.mod new file mode 100644 index 0000000000..82d7bbd62d --- /dev/null +++ b/jetty-util/src/main/config/modules/logging.mod @@ -0,0 +1,7 @@ +# +# Jetty std err/out logging +# + +etc/jetty-logging.xml + +INI=# jetty.log.retain=90
\ No newline at end of file diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/modules/demo.mod b/tests/test-webapps/test-jetty-webapp/src/main/config/modules/demo.mod index 77dfd0be12..9312d07fb8 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/config/modules/demo.mod +++ b/tests/test-webapps/test-jetty-webapp/src/main/config/modules/demo.mod @@ -14,3 +14,6 @@ LIB=demo/lib/*.jar demo/test-realm.xml demo/jetty-demo.xml + +INI=demo.realm=demo/realm.properties +INI=jaas.login.conf=demo/login.conf |