本文整理了Java中org.eclipse.jetty.server.Server.setGracefulShutdown()
方法的一些代码示例,展示了Server.setGracefulShutdown()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.setGracefulShutdown()
方法的具体详情如下:
包路径:org.eclipse.jetty.server.Server
类名称:Server
方法名:setGracefulShutdown
[英]Set graceful shutdown timeout. If set, the internal doStop()
method will not immediately stop the server. Instead, all Connectors will be closed so that new connections will not be accepted and all handlers that implement Graceful will be put into the shutdown mode so that no new requests will be accepted, but existing requests can complete. The server will then wait the configured timeout before stopping.
[中]设置关机超时。如果设置,内部doStop()
方法不会立即停止服务器。相反,所有连接器都将关闭,这样新的连接将不会被接受,所有实现优雅的处理程序将被置于关闭模式,这样新的请求将不会被接受,但现有的请求可以完成。然后,服务器将在停止之前等待配置的超时。
代码示例来源:origin: 4thline/cling
protected void resetServer() {
server = new Server(); // Has its own QueuedThreadPool
server.setGracefulShutdown(1000); // Let's wait a second for ongoing transfers to complete
}
代码示例来源:origin: kingthy/TVRemoteIME
protected void resetServer() {
server = new Server(); // Has its own QueuedThreadPool
server.setGracefulShutdown(1000); // Let's wait a second for ongoing transfers to complete
}
代码示例来源:origin: com.j256.simplejmx/simplejmx
/**
* Stop the internal Jetty web server and associated classes.
*/
public void stop() throws Exception {
server.setGracefulShutdown(100);
server.stop();
server = null;
}
代码示例来源:origin: j256/simplejmx
/**
* Stop the internal Jetty web server and associated classes.
*/
public void stop() throws Exception {
if (server != null) {
server.setGracefulShutdown(100);
server.stop();
server = null;
}
}
代码示例来源:origin: org.fourthline.cling/cling-core
protected void resetServer() {
server = new Server(); // Has its own QueuedThreadPool
server.setGracefulShutdown(1000); // Let's wait a second for ongoing transfers to complete
}
代码示例来源:origin: ombre42/jrobotremoteserver
/**
* A non-blocking method for stopping the remote server that allows requests
* to complete within the given timeout before shutting down the server. New
* connections will not be accepted after calling this.
*
* @param timeoutMS
* the milliseconds to wait for existing request to complete
* before stopping the server
*/
public void stop(int timeoutMS) throws Exception {
log.info("Robot Framework remote server stopping");
if (timeoutMS > 0) {
server.setGracefulShutdown(timeoutMS);
Thread stopper = new Thread() {
@Override
public void run() {
try {
server.stop();
} catch (Throwable e) {
log.error(String.format("Failed to stop the server: %s", e.getMessage()), e);
}
}
};
stopper.start();
} else {
server.stop();
}
}
代码示例来源:origin: sdorra/scm-manager
/**
* Stop embedded webserver. Use {@link Server#stop()} to fix windows service.
*
* @see <a href="http://goo.gl/Zfy0Ev">http://goo.gl/Zfy0Ev</a>
*/
public void stopServer()
{
try
{
server.setGracefulShutdown(GRACEFUL_TIMEOUT);
server.setStopAtShutdown(true);
server.stop();
initialized = false;
}
catch (Exception ex)
{
ex.printStackTrace(System.err);
}
}
代码示例来源:origin: com.truward.brikar/brikar-server
protected void setShutdownStrategy(@Nonnull Server server) {
// stop receiving connections after given amount of milliseconds
final int shutdownDelay = propertyResolver
.getProperty(CONFIG_KEY_SHUTDOWN_DELAY, Integer.class, DEFAULT_SHUTDOWN_DELAY);
getLogger().info("Using shutdownDelay={}", shutdownDelay);
server.setGracefulShutdown(shutdownDelay);
// stop server if SIGINT received
server.setStopAtShutdown(true);
}
代码示例来源:origin: org.schemarepo/schema-repo-server
server.dumpStdErr();
server.setStopAtShutdown(stopAtShutdown);
server.setGracefulShutdown(gracefulShutdown);
return server;
代码示例来源:origin: schema-repo/schema-repo
server.dumpStdErr();
server.setStopAtShutdown(stopAtShutdown);
server.setGracefulShutdown(gracefulShutdown);
return server;
代码示例来源:origin: org.jmockring/jmockring-jetty
/**
* Start Up the server
*/
private void startServer() {
Server srv = new Server();
srv.setStopAtShutdown(true);
srv.setGracefulShutdown(5000);
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(Integer.valueOf(configuration.getProperties().getProperty("jetty.threads.max", "250")));
srv.setThreadPool(threadPool);
Connector connector = new SelectChannelConnector();
connector.setPort(port);
connector.setMaxIdleTime(30000);
srv.setConnectors(new Connector[]{connector});
try {
List<ServletContextHandler> contexts = initialiseAndCreateContexts();
HandlerCollection handlerCollection = getHandlerCollection(srv, contexts);
srv.setHandler(handlerCollection);
srv.start();
srv.join();
} catch (Exception e) {
log.error("Exception: ", e);
e.printStackTrace();
}
}
代码示例来源:origin: org.apache.servicemix/servicemix-http
server.setGracefulShutdown(serverGracefulTimeout);
server.setStopAtShutdown(true);
代码示例来源:origin: com.azaptree/azaptree-http-service
private void configureServer(final HttpServiceConfig config) {
server.addConnector(createSelectChannelConnector(config));
server.setThreadPool(new ExecutorThreadPoolWithGracefulShutdown(config.getRequestExcecutor(), config.getGracefulShutdownTimeoutSecs()));
if (config.getGracefulShutdownTimeoutSecs() > 0) {
server.setGracefulShutdown(1);
}
final HandlerList handlerList = new HandlerList();
handlerList.setHandlers(new Handler[] { config.getHttpRequestHandler(), new DefaultHandler() });
server.setHandler(handlerList);
server.setDumpAfterStart(true);
server.setDumpBeforeStop(true);
}
代码示例来源:origin: epam/Wilma
/**
* Creates a new instance of {@link Server} with the given port,
* request response buffer size and response buffer size.
* @param serverProperties the properties required to configure the server
* @return the instance
*/
public Server createServer(final ServerProperties serverProperties) {
Server server = new Server();
Connector connector = new SelectChannelConnector();
connector.setPort(serverProperties.getProxyPort());
connector.setRequestBufferSize(serverProperties.getRequestBufferSize());
connector.setResponseBufferSize(serverProperties.getResponseBufferSize());
server.setConnectors(new Connector[]{connector});
server.setGracefulShutdown(SHUTDOWN_TIMEOUT);
server.setStopAtShutdown(true);
return server;
}
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jetty
/**
* Returns the wrapped Jetty server.
*
* @return The wrapped Jetty server.
*/
protected Server getWrappedServer() {
if (this.wrappedServer == null) {
this.wrappedServer = new WrappedServer(this);
// Configuring the thread pool
QueuedThreadPool btp = new QueuedThreadPool();
btp.setMaxIdleTimeMs(getThreadMaxIdleTimeMs());
btp.setMaxThreads(getMaxThreads());
btp.setMinThreads(getMinThreads());
getWrappedServer().setThreadPool(btp);
if (getGracefulShutdown() > 0) {
getWrappedServer().setGracefulShutdown(getGracefulShutdown());
}
}
return this.wrappedServer;
}
内容来源于网络,如有侵权,请联系作者删除!