From b3e821c75f9b7f6aa5c9ad74bfae389a689fd428 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Thu, 16 Mar 2023 17:41:02 +0100 Subject: [PATCH 1/3] Set new release version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 96c91f5f6a..24232e8055 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.warning.mode=all org.gradle.console=plain # Gradle -version=2.6.4 +version=2.6.5 group=com.hexagonkt description=The atoms of your platform From e960216fe0294c55ec69800636efa2c79c9f4660 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 19 Mar 2023 14:04:15 +0100 Subject: [PATCH 2/3] Improve packaging --- gradle/application.gradle | 37 +++++-------------------------------- gradle/dokka.gradle | 9 ++++++++- site/pages/gradle.md | 3 --- 3 files changed, 13 insertions(+), 36 deletions(-) diff --git a/gradle/application.gradle b/gradle/application.gradle index b4ff80405c..6829f7094a 100644 --- a/gradle/application.gradle +++ b/gradle/application.gradle @@ -66,6 +66,7 @@ tasks.register("jpackage") { final String modules = findProperty("modules") ?: "java.logging" final String jarAllName = "$name-all-${version}.jar" final java.nio.file.Path jarAll = buildDir.resolve("libs/$jarAllName") + final java.nio.file.Path jpackageJar = buildDir.resolve("jpackage/$jarAllName") List command = [ "${System.getenv("JAVA_HOME")}/bin/jpackage", @@ -86,7 +87,8 @@ tasks.register("jpackage") { tmp.mkdirs() buildDir.resolve(name).toFile().deleteDir() - java.nio.file.Files.copy(jarAll, buildDir.resolve("jpackage/$jarAllName")) + jpackageJar.toFile().delete() + java.nio.file.Files.copy(jarAll, jpackageJar) exec { workingDir(buildDir.toFile()) @@ -102,7 +104,7 @@ tasks.register("tarJpackage", Tar) { from(buildDir.toPath().resolve(project.name).toFile()) compression = Compression.BZIP2 - archiveFileName.set("${project.name}-${project.version}.tbz2") + archiveFileName.set("${project.name}-${project.version}-jpackage.tbz2") destinationDirectory.set(buildDir.toPath().resolve("distributions").toFile()) } @@ -154,35 +156,6 @@ tasks.register("tarJlink", Tar) { from(buildDir.toPath().resolve(project.name).toFile()) compression = Compression.BZIP2 - archiveFileName.set("${project.name}-${project.version}.tbz2") + archiveFileName.set("${project.name}-${project.version}-jlink.tbz2") destinationDirectory.set(buildDir.toPath().resolve("distributions").toFile()) } - -tasks.register("watch") { - group = "application" - description = "Run application in other thread. Allows the possibility to watch source changes." - dependsOn("classes") - - doLast { - final JavaExec runTask = run - - // NOTE: these two statements are *REQUIRED* to load classpath and main class - runTask.classpath.each { it.toString() } - runTask.mainClass.toString() - - ByteArrayOutputStream out = new ByteArrayOutputStream() - exec { - commandLine("jps", "-l") - standardOutput = out - } - out.toString().readLines() - .findAll { it.endsWith(runTask.mainClass.get()) } - .collect { it.split(" ")[0] } - .each { pid -> exec { commandLine("kill", pid) } } - - Thread.startDaemon { - runTask.setIgnoreExitValue(true) - runTask.actions.each { action -> action.execute(runTask) } - } - } -} diff --git a/gradle/dokka.gradle b/gradle/dokka.gradle index f031c9b16c..9af54c5e98 100644 --- a/gradle/dokka.gradle +++ b/gradle/dokka.gradle @@ -28,7 +28,14 @@ setUpDokka(dokkaHtmlPartial) setUpDokka(dokkaJavadoc) private void setUpDokka(final Object dokkaTask) { - dokkaTask.dependsOn("compileJava", "compileKotlin", "processResources", "processTestResources") + dokkaTask.dependsOn( + "compileJava", + "compileKotlin", + "compileTestKotlin", + "processResources", + "processTestResources" + ) + dokkaTask.moduleName.set(project.name) dokkaTask.offlineMode.set(true) dokkaTask.dokkaSourceSets { diff --git a/site/pages/gradle.md b/site/pages/gradle.md index 0c0114d7c8..00086a7777 100644 --- a/site/pages/gradle.md +++ b/site/pages/gradle.md @@ -115,9 +115,6 @@ Gradle's script for a service or application. It adds these extra tasks: * buildInfo: add configuration file (`META-INF/build.properties`) with build variables to the package. It is executed automatically before compiling classes. -* watch: run the application in another thread. Allows the possibility to watch source changes. To - run the application and watch for changes you need to execute this task with the `--continuous` - (`-t`) Gradle flag. Ie: `gw -t watch`. * jarAll: creates a single JAR with all dependencies, and the application main class set up. This task is an alternative to the Gradle `installDist` task. * jlink: create an application distribution based on a jlink generated JRE. From 6386b3fe8887227e5fdce2423ea0eb18ffc4afed Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 19 Mar 2023 15:25:21 +0100 Subject: [PATCH 3/3] Improve Netty resource usage --- .../http/server/netty/NettyServerAdapter.kt | 15 +++------------ .../server/netty/epoll/NettyEpollServerAdapter.kt | 11 +++-------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/http_server_netty/src/main/kotlin/com/hexagonkt/http/server/netty/NettyServerAdapter.kt b/http_server_netty/src/main/kotlin/com/hexagonkt/http/server/netty/NettyServerAdapter.kt index 8e38fe8670..a25dd5f2ca 100644 --- a/http_server_netty/src/main/kotlin/com/hexagonkt/http/server/netty/NettyServerAdapter.kt +++ b/http_server_netty/src/main/kotlin/com/hexagonkt/http/server/netty/NettyServerAdapter.kt @@ -43,7 +43,6 @@ import kotlin.Int.Companion.MAX_VALUE */ open class NettyServerAdapter( private val bossGroupThreads: Int = 1, - private val workerGroupThreads: Int = 0, private val executorThreads: Int = Jvm.cpuCount * 2, private val soBacklog: Int = 4 * 1_024, private val soReuseAddr: Boolean = true, @@ -58,7 +57,6 @@ open class NettyServerAdapter( constructor() : this( bossGroupThreads = 1, - workerGroupThreads = 0, executorThreads = Jvm.cpuCount * 2, soBacklog = 4 * 1_024, soReuseAddr = true, @@ -76,7 +74,6 @@ open class NettyServerAdapter( override fun startUp(server: HttpServer) { val bossGroup = groupSupplier(bossGroupThreads) - val workerGroup = groupSupplier(workerGroupThreads) val executorGroup = if (executorThreads > 0) DefaultEventExecutorGroup(executorThreads) else null @@ -89,7 +86,7 @@ open class NettyServerAdapter( .byMethod() .mapKeys { HttpMethod.valueOf(it.key.toString()) } - val nettyServer = serverBootstrapSupplier(bossGroup, workerGroup) + val nettyServer = serverBootstrapSupplier(bossGroup) .childHandler(createInitializer(sslSettings, handlers, executorGroup, settings)) val address = settings.bindAddress @@ -98,11 +95,9 @@ open class NettyServerAdapter( nettyChannel = future.channel() bossEventLoop = bossGroup - workerEventLoop = workerGroup } catch (e: Exception) { bossGroup.shutdownGracefully() - workerGroup.shutdownGracefully() executorGroup?.shutdownGracefully() } } @@ -110,11 +105,8 @@ open class NettyServerAdapter( open fun groupSupplier(it: Int): MultithreadEventLoopGroup = NioEventLoopGroup(it) - open fun serverBootstrapSupplier( - bossGroup: MultithreadEventLoopGroup, - workerGroup: MultithreadEventLoopGroup, - ): ServerBootstrap = - ServerBootstrap().group(bossGroup, workerGroup) + open fun serverBootstrapSupplier(bossGroup: MultithreadEventLoopGroup): ServerBootstrap = + ServerBootstrap().group(bossGroup) .channel(NioServerSocketChannel::class.java) .option(ChannelOption.SO_BACKLOG, soBacklog) .option(ChannelOption.SO_REUSEADDR, soReuseAddr) @@ -186,7 +178,6 @@ open class NettyServerAdapter( override fun options(): Map = fieldsMapOf( NettyServerAdapter::bossGroupThreads to bossGroupThreads, - NettyServerAdapter::workerGroupThreads to workerGroupThreads, NettyServerAdapter::executorThreads to executorThreads, NettyServerAdapter::soBacklog to soBacklog, NettyServerAdapter::soKeepAlive to soKeepAlive, diff --git a/http_server_netty_epoll/src/main/kotlin/com/hexagonkt/http/server/netty/epoll/NettyEpollServerAdapter.kt b/http_server_netty_epoll/src/main/kotlin/com/hexagonkt/http/server/netty/epoll/NettyEpollServerAdapter.kt index 8f6c2932c2..e3f8125688 100644 --- a/http_server_netty_epoll/src/main/kotlin/com/hexagonkt/http/server/netty/epoll/NettyEpollServerAdapter.kt +++ b/http_server_netty_epoll/src/main/kotlin/com/hexagonkt/http/server/netty/epoll/NettyEpollServerAdapter.kt @@ -16,30 +16,25 @@ import io.netty.channel.epoll.EpollServerSocketChannel */ class NettyEpollServerAdapter( bossGroupThreads: Int = 1, - workerGroupThreads: Int = 0, executorThreads: Int = Jvm.cpuCount * 2, private val soBacklog: Int = 4 * 1_024, private val soReuseAddr: Boolean = true, private val soKeepAlive: Boolean = true, ) : NettyServerAdapter( bossGroupThreads, - workerGroupThreads, executorThreads, soBacklog, soReuseAddr, soKeepAlive, ) { - constructor() : this(1, 0, Jvm.cpuCount * 2, 4 * 1_024, true, true) + constructor() : this(1, Jvm.cpuCount * 2, 4 * 1_024, true, true) override fun groupSupplier(it: Int): MultithreadEventLoopGroup = EpollEventLoopGroup(it) - override fun serverBootstrapSupplier( - bossGroup: MultithreadEventLoopGroup, - workerGroup: MultithreadEventLoopGroup, - ): ServerBootstrap = - ServerBootstrap().group(bossGroup, workerGroup) + override fun serverBootstrapSupplier(bossGroup: MultithreadEventLoopGroup): ServerBootstrap = + ServerBootstrap().group(bossGroup) .channel(EpollServerSocketChannel::class.java) .option(EpollChannelOption.SO_REUSEPORT, true) .option(ChannelOption.SO_BACKLOG, soBacklog)