Merge pull request #9 from usbharu/feature/native

Feature/native
This commit is contained in:
usbharu 2023-04-22 11:26:07 +09:00 committed by GitHub
commit 8101354e91
10 changed files with 1523 additions and 7 deletions

View File

@ -8,13 +8,14 @@ val koin_version: String by project
plugins {
kotlin("jvm") version "1.8.10"
id("io.ktor.plugin") version "2.2.4"
id("org.graalvm.buildtools.native") version "0.9.21"
// id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10"
}
group = "dev.usbharu"
version = "0.0.1"
application {
mainClass.set("io.ktor.server.netty.EngineMain")
mainClass.set("io.ktor.server.cio.EngineMain")
val isDevelopment: Boolean = project.ext.has("development")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
@ -52,7 +53,7 @@ dependencies {
implementation("com.h2database:h2:$h2_version")
implementation("org.xerial:sqlite-jdbc:3.40.1.0")
implementation("io.ktor:ktor-server-websockets-jvm:$ktor_version")
implementation("io.ktor:ktor-server-netty-jvm:$ktor_version")
implementation("io.ktor:ktor-server-cio-jvm:$ktor_version")
implementation("ch.qos.logback:logback-classic:$logback_version")
implementation("io.insert-koin:koin-core:$koin_version")
@ -97,3 +98,29 @@ ktor {
localImageName.set("hideout")
}
}
graalvmNative {
binaries {
named("main") {
fallback.set(false)
verbose.set(true)
agent{
enabled.set(false)
}
buildArgs.add("--initialize-at-build-time=io.ktor,kotlin,kotlinx")
// buildArgs.add("--trace-class-initialization=ch.qos.logback.classic.Logger")
// buildArgs.add("--trace-object-instantiation=ch.qos.logback.core.AsyncAppenderBase"+"$"+"Worker")
// buildArgs.add("--trace-object-instantiation=ch.qos.logback.classic.Logger")
buildArgs.add("--initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback")
// buildArgs.add("--trace-object-instantiation=kotlinx.coroutines.channels.ArrayChannel")
buildArgs.add("--initialize-at-build-time=kotlinx.coroutines.channels.ArrayChannel")
buildArgs.add("-H:+InstallExitHandlers")
buildArgs.add("-H:+ReportUnsupportedElementsAtRuntime")
buildArgs.add("-H:+ReportExceptionStackTraces")
runtimeArgs.add("-config=$buildDir/resources/main/application-native.conf")
imageName.set("graal-server")
}
}
}

View File

@ -30,7 +30,7 @@ import kjob.core.kjob
import org.jetbrains.exposed.sql.Database
import org.koin.ktor.ext.inject
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
fun main(args: Array<String>): Unit = io.ktor.server.cio.EngineMain.main(args)
val Application.property: Application.(propertyName: String) -> String
get() = {

View File

@ -13,7 +13,7 @@ class KJobJobQueueParentService(private val database: Database) : JobQueueParent
private val logger = LoggerFactory.getLogger(this::class.java)
val kjob: KJob = kjob(ExposedKJob) {
connectionDatabase = database
connectionDatabase = database
isWorker = false
}.start()
@ -21,8 +21,8 @@ class KJobJobQueueParentService(private val database: Database) : JobQueueParent
}
override suspend fun <J : Job> schedule(job: J,block:ScheduleContext<J>.(J)->Unit) {
logger.debug("schedule job={}",job.name)
kjob.schedule(job,block)
override suspend fun <J : Job> schedule(job: J, block: ScheduleContext<J>.(J) -> Unit) {
logger.debug("schedule job={}", job.name)
kjob.schedule(job, block)
}
}

View File

@ -0,0 +1,31 @@
[
{
"name": "sun.management.VMManagementImpl",
"fields": [
{
"name": "compTimeMonitoringSupport"
},
{
"name": "currentThreadCpuTimeSupport"
},
{
"name": "objectMonitorUsageSupport"
},
{
"name": "otherThreadCpuTimeSupport"
},
{
"name": "remoteDiagnosticCommandsSupport"
},
{
"name": "synchronizerUsageSupport"
},
{
"name": "threadAllocatedMemorySupport"
},
{
"name": "threadContentionMonitoringSupport"
}
]
}
]

View File

@ -0,0 +1,8 @@
[
{
"type": "agent-extracted",
"classes": [
]
}
]

View File

@ -0,0 +1,3 @@
[
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
{
"resources": {
"includes": [
{
"pattern": "\\QMETA-INF/services/ch.qos.logback.classic.spi.Configurator\\E"
},
{
"pattern": "\\QMETA-INF/services/io.ktor.server.config.ConfigLoader\\E"
},
{
"pattern": "\\QMETA-INF/services/java.sql.Driver\\E"
},
{
"pattern": "\\QMETA-INF/services/kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader\\E"
},
{
"pattern": "\\QMETA-INF/services/kotlin.reflect.jvm.internal.impl.resolve.ExternalOverridabilityCondition\\E"
},
{
"pattern": "\\QMETA-INF/services/org.jetbrains.exposed.sql.DatabaseConnectionAutoRegistration\\E"
},
{
"pattern": "\\QMETA-INF/services/org.slf4j.spi.SLF4JServiceProvider\\E"
},
{
"pattern": "\\Qapplication.conf\\E"
},
{
"pattern": "\\Qlogback.xml\\E"
},
{
"pattern": "\\Qorg/fusesource/jansi/internal/native/Windows/x86_64/jansi.dll\\E"
},
{
"pattern": "\\Qorg/fusesource/jansi/jansi.properties\\E"
},
{
"pattern": "\\Qorg/h2/util/data.zip\\E"
},
{
"pattern": "\\Qstatic/assets/index-c7cbea7a.js\\E"
},
{
"pattern": "\\Qstatic/index.html\\E"
},
{
"pattern":"\\Qkotlin/kotlin.kotlin_builtins\\E"
}
]
},
"bundles": [
]
}

View File

@ -0,0 +1,11 @@
{
"lambdaCapturingTypes": [
],
"types": [
],
"proxies": [
]
}

View File

@ -0,0 +1,22 @@
ktor {
development = false
deployment {
port = 8080
port = ${?PORT}
// watch = [classes, resources]
}
application {
modules = [dev.usbharu.hideout.ApplicationKt.parent,dev.usbharu.hideout.ApplicationKt.worker]
}
}
hideout {
url = "http://localhost:8080"
database {
url = "jdbc:h2:./test;MODE=POSTGRESQL"
driver = "org.h2.Driver"
username = ""
password = ""
}
}