Issue #2103 open connectors before starting (#2104) Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
ad8f2abbb4
commit
d2efb7f548
|
@ -346,6 +346,8 @@ public class Server extends HandlerWrapper implements Attributes
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws Exception
|
protected void doStart() throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Create an error handler if there is none
|
// Create an error handler if there is none
|
||||||
if (_errorHandler==null)
|
if (_errorHandler==null)
|
||||||
|
@ -371,7 +373,7 @@ public class Server extends HandlerWrapper implements Attributes
|
||||||
String gitHash = Jetty.GIT_HASH;
|
String gitHash = Jetty.GIT_HASH;
|
||||||
String timestamp = Jetty.BUILD_TIMESTAMP;
|
String timestamp = Jetty.BUILD_TIMESTAMP;
|
||||||
|
|
||||||
LOG.info("jetty-{}; built: {}; git: {}; jvm {}", getVersion(), timestamp, gitHash, JavaVersion.VERSION);
|
LOG.info("jetty-{}, build timestamp: {}, git hash: {}", getVersion(), timestamp, gitHash);
|
||||||
if (!Jetty.STABLE)
|
if (!Jetty.STABLE)
|
||||||
{
|
{
|
||||||
LOG.warn("THIS IS NOT A STABLE RELEASE! DO NOT USE IN PRODUCTION!");
|
LOG.warn("THIS IS NOT A STABLE RELEASE! DO NOT USE IN PRODUCTION!");
|
||||||
|
@ -381,16 +383,28 @@ public class Server extends HandlerWrapper implements Attributes
|
||||||
HttpGenerator.setJettyVersion(HttpConfiguration.SERVER_VERSION);
|
HttpGenerator.setJettyVersion(HttpConfiguration.SERVER_VERSION);
|
||||||
|
|
||||||
MultiException mex=new MultiException();
|
MultiException mex=new MultiException();
|
||||||
|
|
||||||
|
// Open network connector to ensure ports are available
|
||||||
|
_connectors.stream().filter(NetworkConnector.class::isInstance).map(NetworkConnector.class::cast).forEach(connector->
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
super.doStart();
|
connector.open();
|
||||||
}
|
}
|
||||||
catch(Throwable e)
|
catch(Throwable th)
|
||||||
{
|
{
|
||||||
mex.add(e);
|
mex.add(th);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// start connectors last
|
// Throw now if verified start sequence and there was an open exception
|
||||||
|
mex.ifExceptionThrow();
|
||||||
|
|
||||||
|
// Start the server and components, but not connectors!
|
||||||
|
// #start(LifeCycle) is overridden so that connectors are not started
|
||||||
|
super.doStart();
|
||||||
|
|
||||||
|
// start connectors
|
||||||
for (Connector connector : _connectors)
|
for (Connector connector : _connectors)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -403,12 +417,32 @@ public class Server extends HandlerWrapper implements Attributes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mex.ifExceptionThrow();
|
||||||
|
LOG.info(String.format("Started @%dms",Uptime.getUptime()));
|
||||||
|
}
|
||||||
|
catch(Throwable e1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Stop any components already started!
|
||||||
|
super.doStop();
|
||||||
|
}
|
||||||
|
catch(Exception e2)
|
||||||
|
{
|
||||||
|
e1.addSuppressed(e2);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// Close any connectors that were opened
|
||||||
|
_connectors.stream().filter(NetworkConnector.class::isInstance).map(NetworkConnector.class::cast).forEach(NetworkConnector::close);
|
||||||
|
}
|
||||||
|
throw e1;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
if (isDumpAfterStart())
|
if (isDumpAfterStart())
|
||||||
dumpStdErr();
|
dumpStdErr();
|
||||||
|
}
|
||||||
mex.ifExceptionThrow();
|
|
||||||
|
|
||||||
LOG.info(String.format("Started @%dms",Uptime.getUptime()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue