diff --git a/CHANGELOG.md b/CHANGELOG.md index 94c441c..404b411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Proteus Changelog. ## Unreleased ### No issue +**Add graceful shutdown option.** + + +[cc429604e4feaa6](https://github.com/noboomu/proteus/commit/cc429604e4feaa6) Joshua Bauer *2022-07-18 20:30:03* + **Bump version** diff --git a/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java b/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java index 4243d6e..354097c 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java @@ -33,6 +33,7 @@ import org.apache.commons.lang3.time.DurationFormatUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.xnio.Options; import org.xnio.Xnio; import org.xnio.XnioWorker; @@ -412,11 +413,13 @@ public void buildServer() httpPort = Integer.parseInt(System.getProperty("http.port")); } + final int processorCount = Runtime.getRuntime().availableProcessors(); + Undertow.Builder undertowBuilder = Undertow.builder().addHttpListener(httpPort, config.getString("application.host")) .setBufferSize(Long.valueOf(config.getMemorySize("undertow.bufferSize").toBytes()).intValue()) - .setIoThreads(Runtime.getRuntime().availableProcessors() * config.getInt("undertow.ioThreadsMultiplier")) - .setWorkerThreads(Runtime.getRuntime().availableProcessors() * config.getInt("undertow.workerThreadMultiplier")) + .setIoThreads(processorCount * config.getInt("undertow.ioThreadsMultiplier")) + .setWorkerThreads(processorCount * config.getInt("undertow.workerThreadsMultiplier")) .setDirectBuffers(config.getBoolean("undertow.directBuffers")) .setSocketOption(org.xnio.Options.BACKLOG, config.getInt("undertow.socket.backlog")) .setSocketOption(org.xnio.Options.REUSE_ADDRESSES, config.getBoolean("undertow.socket.reuseAddresses")) @@ -430,6 +433,7 @@ public void buildServer() .setServerOption(UndertowOptions.MAX_BUFFERED_REQUEST_SIZE, config.getInt("undertow.server.maxBufferedRequestSize")) .setHandler(handler); + if (config.getBoolean("undertow.ssl.enabled")) { try diff --git a/proteus-core/src/main/resources/reference.conf b/proteus-core/src/main/resources/reference.conf index 0adf2a9..25eeb9f 100644 --- a/proteus-core/src/main/resources/reference.conf +++ b/proteus-core/src/main/resources/reference.conf @@ -182,8 +182,8 @@ undertow socket { backlog=10000 reuseAddresses=true - readTimeout=30000 - writeTimeout=30000 + readTimeout=90000 + writeTimeout=90000 } @@ -197,7 +197,7 @@ undertow # x AvailableProcessors ioThreadsMultiplier=2 - workerThreadMultiplier=10 + workerThreadsMultiplier=10 bufferSize=16k directBuffers=true } diff --git a/proteus-core/src/test/java/io/sinistral/proteus/test/controllers/Tests.java b/proteus-core/src/test/java/io/sinistral/proteus/test/controllers/Tests.java index 57c5017..1f3da3e 100644 --- a/proteus-core/src/test/java/io/sinistral/proteus/test/controllers/Tests.java +++ b/proteus-core/src/test/java/io/sinistral/proteus/test/controllers/Tests.java @@ -820,7 +820,7 @@ public ServerResponse> complexParameters( @GET @Path("secure/resource") @Produces(MediaType.APPLICATION_JSON) - public ServerResponse> responseSecureContext() + public ServerResponse> responseSecureContext(ServerRequest request) { Map responseMap = new HashMap<>(); responseMap.put("secure",true); diff --git a/proteus-core/src/test/resources/application.conf b/proteus-core/src/test/resources/application.conf index 76e4c18..a586403 100644 --- a/proteus-core/src/test/resources/application.conf +++ b/proteus-core/src/test/resources/application.conf @@ -98,7 +98,7 @@ undertow # x AvailableProcessors ioThreadsMultiplier = 2 - workerThreadMultiplier = 12 + workerThreadsMultiplier = 12 bufferSize = 16K directBuffers = true } diff --git a/proteus-openapi/src/test/resources/application.conf b/proteus-openapi/src/test/resources/application.conf index 9b64074..40080e7 100644 --- a/proteus-openapi/src/test/resources/application.conf +++ b/proteus-openapi/src/test/resources/application.conf @@ -130,7 +130,7 @@ undertow enableHttp2=false # x AvailableProcessors ioThreadsMultiplier = 2 - workerThreadMultiplier = 8 + workerThreadsMultiplier = 8 bufferSize = 16K directBuffers = true }