[Bug 415825] fix stop support in modular start setup
This commit is contained in:
parent
14ec13000d
commit
e54a9246e8
|
@ -346,6 +346,13 @@ public class Main
|
|||
StartLog.debug("Parsing collected arguments");
|
||||
args.parseCommandLine();
|
||||
|
||||
// 4.5) check if you need to continue building module resolution
|
||||
// (ie should be able to stop server without building module tree, etc)
|
||||
if ( !args.isRun() )
|
||||
{
|
||||
return args;
|
||||
}
|
||||
|
||||
// 5) Module Registration
|
||||
Modules modules = new Modules();
|
||||
StartLog.debug("Registering all modules");
|
||||
|
@ -465,6 +472,22 @@ public class Main
|
|||
enable(args,module,true);
|
||||
}
|
||||
|
||||
if (args.isStopCommand())
|
||||
{
|
||||
int stopPort = Integer.parseInt(args.getProperties().getProperty("STOP.PORT"));
|
||||
String stopKey = args.getProperties().getProperty("STOP.KEY");
|
||||
|
||||
if (args.getProperties().getProperty("STOP.WAIT") != null)
|
||||
{
|
||||
int stopWait = Integer.parseInt(args.getProperties().getProperty("STOP.PORT"));
|
||||
|
||||
stop(stopPort,stopKey,stopWait);
|
||||
}
|
||||
else
|
||||
{
|
||||
stop(stopPort,stopKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Informational command line, don't run jetty
|
||||
if (!args.isRun())
|
||||
|
@ -472,6 +495,8 @@ public class Main
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// execute Jetty in another JVM
|
||||
if (args.isExec())
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
|
@ -372,10 +371,6 @@ public class StartArgs
|
|||
cmd.addRawArg("-Djetty.home=" + baseHome.getHome());
|
||||
cmd.addRawArg("-Djetty.base=" + baseHome.getBase());
|
||||
|
||||
// Special Stop/Shutdown properties
|
||||
ensureSystemPropertySet("STOP.PORT");
|
||||
ensureSystemPropertySet("STOP.KEY");
|
||||
|
||||
// System Properties
|
||||
for (String propKey : systemPropertyKeys)
|
||||
{
|
||||
|
@ -388,6 +383,11 @@ public class StartArgs
|
|||
cmd.addRawArg(getMainClassname());
|
||||
}
|
||||
|
||||
// Special Stop/Shutdown properties
|
||||
ensureSystemPropertySet("STOP.PORT");
|
||||
ensureSystemPropertySet("STOP.KEY");
|
||||
ensureSystemPropertySet("STOP.WAIT");
|
||||
|
||||
// Check if we need to pass properties as a file
|
||||
if (properties.size() > 0)
|
||||
{
|
||||
|
@ -537,12 +537,6 @@ public class StartArgs
|
|||
throw new UsageException(ERR_BAD_ARG,"%s not allowed in %s",arg,source);
|
||||
stopCommand = true;
|
||||
run = false;
|
||||
//
|
||||
// int port = Integer.parseInt(_config.getProperty("STOP.PORT","-1"));
|
||||
// String key = _config.getProperty("STOP.KEY",null);
|
||||
// int timeout = Integer.parseInt(_config.getProperty("STOP.WAIT","0"));
|
||||
// stop(port,key,timeout);
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,11 @@
|
|||
package org.eclipse.jetty.start;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MainTest
|
||||
|
@ -52,6 +49,25 @@ public class MainTest
|
|||
ConfigurationAssert.assertConfiguration(baseHome,args,"assert-home.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStopProcessing() throws Exception
|
||||
{
|
||||
List<String> cmdLineArgs = new ArrayList<>();
|
||||
cmdLineArgs.add("--stop");
|
||||
cmdLineArgs.add("STOP.PORT=10000");
|
||||
cmdLineArgs.add("STOP.KEY=foo");
|
||||
cmdLineArgs.add("STOP.WAIT=300");
|
||||
|
||||
Main main = new Main();
|
||||
StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()]));
|
||||
System.err.println(args);
|
||||
|
||||
//Assert.assertEquals("--stop should not build module tree", 0, args.getEnabledModules().size());
|
||||
Assert.assertEquals("--stop missing port","10000",args.getProperties().get("STOP.PORT"));
|
||||
Assert.assertEquals("--stop missing key","foo",args.getProperties().get("STOP.KEY"));
|
||||
Assert.assertEquals("--stop missing wait","300",args.getProperties().get("STOP.WAIT"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListConfig() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue