started mechanism uses Properties
list Properties in --dry-run fix start log file
This commit is contained in:
parent
89e70527d3
commit
5edf15241b
|
@ -310,7 +310,7 @@ if [ -z "$JETTY_STATE" ]
|
|||
then
|
||||
JETTY_STATE=$JETTY_BASE/${NAME}.state
|
||||
fi
|
||||
JAVA_OPTIONS+=("-Djetty.state=$JETTY_STATE")
|
||||
JAVA_ARGS+=("jetty.state=$JETTY_STATE")
|
||||
rm -f $JETTY_STATE
|
||||
|
||||
##################################################
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<Call name="addLifeCycleListener">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.util.component.FileNoticeLifeCycleListener">
|
||||
<Arg><SystemProperty name="jetty.state" default="./jetty.state"/></Arg>
|
||||
<Arg><Property name="jetty.state" default="./jetty.state"/></Arg>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
|
|
@ -130,12 +130,16 @@ public class BaseHome
|
|||
|
||||
public BaseHome(CommandLineConfigSource cmdLineSource) throws IOException
|
||||
{
|
||||
StartLog.getInstance().initialize(this,cmdLineSource);
|
||||
|
||||
sources = new ConfigSources();
|
||||
sources.add(cmdLineSource);
|
||||
this.homeDir = cmdLineSource.getHomePath();
|
||||
this.baseDir = cmdLineSource.getBasePath();
|
||||
|
||||
// TODO this is cyclic construction as start log uses BaseHome, but BaseHome constructor
|
||||
// calls other constructors that log. This appears to be a workable sequence.
|
||||
StartLog.getInstance().initialize(this,cmdLineSource);
|
||||
|
||||
sources.add(new JettyBaseConfigSource(cmdLineSource.getBasePath()));
|
||||
sources.add(new JettyHomeConfigSource(cmdLineSource.getHomePath()));
|
||||
|
||||
|
|
|
@ -486,6 +486,7 @@ public class StartArgs
|
|||
cmd.addRawArg(x);
|
||||
}
|
||||
|
||||
cmd.addRawArg("-Djava.io.tmpdir=" + System.getProperty("java.io.tmpdir"));
|
||||
cmd.addRawArg("-Djetty.home=" + baseHome.getHome());
|
||||
cmd.addRawArg("-Djetty.base=" + baseHome.getBase());
|
||||
|
||||
|
@ -506,14 +507,16 @@ public class StartArgs
|
|||
ensureSystemPropertySet("STOP.KEY");
|
||||
ensureSystemPropertySet("STOP.WAIT");
|
||||
|
||||
// Check if we need to pass properties as a file
|
||||
if (properties.size() > 0)
|
||||
// pass properties as args or as a file
|
||||
if (dryRun)
|
||||
{
|
||||
for (Prop p : properties)
|
||||
cmd.addRawArg(CommandLineBuilder.quote(p.key)+"="+CommandLineBuilder.quote(p.value));
|
||||
}
|
||||
else if (properties.size() > 0)
|
||||
{
|
||||
File prop_file = File.createTempFile("start",".properties");
|
||||
if (!dryRun)
|
||||
{
|
||||
prop_file.deleteOnExit();
|
||||
}
|
||||
prop_file.deleteOnExit();
|
||||
try (FileOutputStream out = new FileOutputStream(prop_file))
|
||||
{
|
||||
properties.store(out,"start.jar properties");
|
||||
|
|
|
@ -43,7 +43,7 @@ public class StartLog
|
|||
{
|
||||
if (INSTANCE.debug)
|
||||
{
|
||||
System.out.printf(format + "%n",args);
|
||||
INSTANCE.out.printf(format + "%n",args);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class StartLog
|
|||
{
|
||||
if (INSTANCE.debug)
|
||||
{
|
||||
t.printStackTrace(System.out);
|
||||
t.printStackTrace(INSTANCE.out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,17 +62,17 @@ public class StartLog
|
|||
|
||||
public static void info(String format, Object... args)
|
||||
{
|
||||
System.err.printf("INFO: " + format + "%n",args);
|
||||
INSTANCE.err.printf("INFO: " + format + "%n",args);
|
||||
}
|
||||
|
||||
public static void warn(String format, Object... args)
|
||||
{
|
||||
System.err.printf("WARNING: " + format + "%n",args);
|
||||
INSTANCE.err.printf("WARNING: " + format + "%n",args);
|
||||
}
|
||||
|
||||
public static void warn(Throwable t)
|
||||
{
|
||||
t.printStackTrace(System.err);
|
||||
t.printStackTrace(INSTANCE.err);
|
||||
}
|
||||
|
||||
public static boolean isDebugEnabled()
|
||||
|
@ -81,6 +81,8 @@ public class StartLog
|
|||
}
|
||||
|
||||
private boolean debug = false;
|
||||
private PrintStream out = System.out;
|
||||
private PrintStream err = System.err;
|
||||
|
||||
public void initialize(BaseHome baseHome, CommandLineConfigSource cmdLineSource) throws IOException
|
||||
{
|
||||
|
@ -137,13 +139,12 @@ public class StartLog
|
|||
throw new UsageException(UsageException.ERR_LOGGING,new IOException("Unable to write to: " + startLog.toAbsolutePath()));
|
||||
}
|
||||
|
||||
System.out.println("Logging to " + logfile);
|
||||
|
||||
err.println("StartLog to " + logfile);
|
||||
OutputStream out = Files.newOutputStream(startLog,StandardOpenOption.CREATE,StandardOpenOption.APPEND);
|
||||
PrintStream logger = new PrintStream(out);
|
||||
System.setOut(logger);
|
||||
System.setErr(logger);
|
||||
System.out.println("Establishing " + logfile + " on " + new Date());
|
||||
err=logger;
|
||||
out=logger;
|
||||
err.println("StartLog Establishing " + logfile + " on " + new Date());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@ -156,4 +157,9 @@ public class StartLog
|
|||
{
|
||||
getInstance().debug = true;
|
||||
}
|
||||
|
||||
public static void endStartLog()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1214,6 +1214,11 @@ public class XmlConfiguration
|
|||
{
|
||||
if (arg.toLowerCase(Locale.ENGLISH).endsWith(".properties"))
|
||||
properties.load(Resource.newResource(arg).getInputStream());
|
||||
else if (arg.indexOf('=')>=0)
|
||||
{
|
||||
int i=arg.indexOf('=');
|
||||
properties.put(arg.substring(0,i),arg.substring(i+1));
|
||||
}
|
||||
}
|
||||
|
||||
// For all arguments, parse XMLs
|
||||
|
@ -1221,7 +1226,7 @@ public class XmlConfiguration
|
|||
Object[] obj = new Object[args.length];
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
if (!args[i].toLowerCase(Locale.ENGLISH).endsWith(".properties"))
|
||||
if (!args[i].toLowerCase(Locale.ENGLISH).endsWith(".properties") && (args[i].indexOf('=')<0))
|
||||
{
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(args[i]).getURL());
|
||||
if (last != null)
|
||||
|
|
Loading…
Reference in New Issue