Issue #5263 Jetty Home warning (#5309)

* Issue #5264 Jetty Home warning

Warn when using jetty home as a jetty base

* Issue #5304 HTTP2 HostHeader

 + updated more options doco and handling

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Issue #5264 Jetty Home warning

updates from review
This commit is contained in:
Greg Wilkins 2020-09-22 18:23:44 +02:00 committed by GitHub
parent 12943822f5
commit 592dfb85fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 104 additions and 63 deletions

View File

@ -101,9 +101,7 @@
<!-- handler by context path and virtual host, and the -->
<!-- DefaultHandler, which handles any requests not handled by -->
<!-- the context handlers. -->
<!-- Other handlers may be added to the "Handlers" collection, -->
<!-- for example the jetty-requestlog.xml file adds the -->
<!-- RequestLogHandler after the default handler -->
<!-- Other handlers may be added to the "Handlers" collection. -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">

View File

@ -311,7 +311,7 @@
<argument>jetty.home=${home-directory}</argument>
<argument>jetty.base=${base-directory}</argument>
<argument>--create-startd</argument>
<argument>--add-to-start=server,requestlog,deploy,websocket,ext,resources,client,annotations,jndi,servlets,jsp,jstl,http,https,demo</argument>
<argument>--add-module=server,requestlog,deploy,websocket,ext,resources,client,annotations,jndi,servlets,jsp,jstl,http,https,demo</argument>
</arguments>
</configuration>
<goals>

View File

@ -18,8 +18,10 @@
package org.eclipse.jetty.start;
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
@ -28,6 +30,7 @@ import java.nio.file.PathMatcher;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@ -176,7 +179,9 @@ public class BaseBuilder
{
if (!Files.exists(startini))
{
StartLog.info("create " + baseHome.toShortForm(startini));
if (Files.exists(getBaseHome().getBasePath("start.jar")))
StartLog.warn("creating start.ini in ${jetty.home} is not recommended!");
StartLog.info("create %s", baseHome.toShortForm(startini));
Files.createFile(startini);
modified.set(true);
}
@ -222,18 +227,47 @@ public class BaseBuilder
}
}
if (!newlyAdded.isEmpty())
if ((startArgs.isCreateStartD() && (!Files.exists(startd) || Files.exists(startini))) ||
(!newlyAdded.isEmpty() && !Files.exists(startini) && !Files.exists(startd)))
{
if (!Files.exists(startini) && !Files.exists(startd) && FS.ensureDirectoryExists(startd))
if (Files.exists(getBaseHome().getBasePath("start.jar")) && !startArgs.isCreateStartD())
{
StartLog.warn("creating start.d in ${jetty.home} is not recommended!");
if (!startArgs.isCreateStartD())
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.err.printf("%nProceed (y/N)? ");
String response = input.readLine();
if (Utils.isBlank(response) || !response.toLowerCase(Locale.ENGLISH).startsWith("y"))
System.exit(1);
}
}
if (FS.ensureDirectoryExists(startd))
{
StartLog.info("mkdir " + baseHome.toShortForm(startd));
modified.set(true);
}
if (Files.exists(startini) && Files.exists(startd))
StartLog.warn("Use both %s and %s is deprecated", getBaseHome().toShortForm(startd), getBaseHome().toShortForm(startini));
if (Files.exists(startini) && startArgs.isCreateStartD())
{
int ini = 0;
Path startdStartini = startd.resolve("start.ini");
while (Files.exists(startdStartini))
{
ini++;
startdStartini = startd.resolve("start" + ini + ".ini");
}
Files.move(startini, startdStartini);
modified.set(true);
}
}
boolean useStartD = Files.exists(startd);
if (useStartD && Files.exists(startini))
StartLog.warn("Use of both %s and %s is deprecated", getBaseHome().toShortForm(startd), getBaseHome().toShortForm(startini));
builder.set(useStartD ? new StartDirBuilder(this) : new StartIniBuilder(this));
newlyAdded.stream().map(modules::get).forEach(module ->
{
@ -282,12 +316,9 @@ public class BaseBuilder
}
else
{
StartLog.info("%-15s initialized in %s",
module.getName(),
ini);
StartLog.info("%-15s initialized in %s", module.getName(), ini);
}
});
}
files.addAll(startArgs.getFiles());
if (!files.isEmpty() && processFileResources(files))

View File

@ -230,6 +230,7 @@ public class StartArgs
private boolean dryRun = false;
private final Set<String> dryRunParts = new HashSet<>();
private boolean jpms = false;
private boolean createStartD = false;
private boolean createStartIni = false;
private boolean updateIni = false;
private String mavenBaseUri;
@ -716,7 +717,6 @@ public class StartArgs
Prop p = processSystemProperty(key, value, null);
cmd.addRawArg("-D" + p.key + "=" + getProperties().expand(p.value));
}
else
{
@ -1024,6 +1024,11 @@ public class StartArgs
return version;
}
public boolean isCreateStartD()
{
return createStartD;
}
public boolean isCreateStartIni()
{
return createStartIni;
@ -1289,9 +1294,9 @@ public class StartArgs
licenseCheckRequired = true;
return;
}
if ("--create-startd".equals(arg))
if ("--create-startd".equals(arg) || "--create-start-d".equals(arg))
{
StartLog.warn("--create-startd option is deprecated! By default start.d is used");
createStartD = true;
run = false;
createFiles = true;
licenseCheckRequired = true;

View File

@ -73,6 +73,7 @@ public class DirConfigSource implements ConfigSource
BANNED_ARGS.add("--create-files");
BANNED_ARGS.add("--create-startd");
BANNED_ARGS.add("--create-start-ini");
BANNED_ARGS.add("--create-start-d");
BANNED_ARGS.add("--add-to-startd");
BANNED_ARGS.add("--add-to-start");
BANNED_ARGS.add("--add-module");

View File

@ -120,19 +120,25 @@ Jetty Module Management:
amended in the generated file by specifying those
properties on the command line.
If a module is transitively enabled, it's ini file will not
If a module is transitively enabled, its ini file will not
be generated. An explicit --add-module is required to generate
an ini file.
This option replaces the depecated --add-to-start and --add-to-startd.
This option replaces the deprecated --add-to-start and --add-to-startd.
--update-ini Scan all start.ini and start.d/*.ini files and update
any properties with values specified on the command
line. e.g. --update-ini jetty.http.port=8888
--create-start-d
Create a ${jetty.base}/start.d directory. If a ${jetty.base}/start.ini
files exists, then it is moved into start.d. Using a start.d directory
is the default and this option is only needed to either force the creation of a
${jetty.home}/start.d or to move a start.ini file to start.d
--create-start-ini
Create a ${jetty.base}/start.ini file. If a ${jetty.base}/start.d
directory exists, then all it's contained ini files are concatinated into
directory exists, then all its contained ini files are concatenated into
the start.ini file.
--write-module-graph=<filename>
@ -216,7 +222,7 @@ Properties:
If any of the previous formats is preceded by -D, then a system property is set
as well as a start property.
Each module may define it's own properties. Start properties defined include:
Each module may define its own properties. Start properties defined include:
jetty.home=[directory]
Set the home directory of the jetty distribution.