diff options
author | Florian Dold <florian@dold.me> | 2021-08-07 13:53:30 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-08-07 13:53:30 +0200 |
commit | 7185215e9e3578127afd95a190ec4290ee591589 (patch) | |
tree | 5c5a56a33396addbaf7356f12e2a46d8811d273f /nexus | |
parent | 0a4f8f53f84ad7e172880e0880a670aa651a01a4 (diff) | |
download | libeufin-7185215e9e3578127afd95a190ec4290ee591589.tar.gz libeufin-7185215e9e3578127afd95a190ec4290ee591589.tar.bz2 libeufin-7185215e9e3578127afd95a190ec4290ee591589.zip |
make sure task scheduler is executed
Diffstat (limited to 'nexus')
3 files changed, 7 insertions, 6 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt index 4927b10a..c9508857 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -34,7 +34,6 @@ import com.github.ajalt.clikt.parameters.types.int import execThrowableOrTerminate import com.github.ajalt.clikt.core.* import com.github.ajalt.clikt.parameters.options.versionOption -import io.ktor.client.* import tech.libeufin.nexus.iso20022.parseCamtMessage import tech.libeufin.nexus.server.client import tech.libeufin.util.* @@ -61,8 +60,12 @@ class Serve : CliktCommand("Run nexus HTTP server") { private val logLevel by option() override fun run() { setLogLevel(logLevel) - serverMain(getDbConnFromEnv(NEXUS_DB_ENV_VAR_NAME), host, port) + val dbConn = getDbConnFromEnv(NEXUS_DB_ENV_VAR_NAME) + execThrowableOrTerminate { + dbCreateTables(dbConn) + } startOperationScheduler(client) + serverMain(host, port) } } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt index 7e87c5a7..85287531 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt @@ -24,6 +24,7 @@ import com.cronutils.model.time.ExecutionTime import com.cronutils.parser.CronParser import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import io.ktor.client.HttpClient +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.time.delay diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt index a3b17c43..3c20fbf1 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt @@ -168,10 +168,7 @@ val client = HttpClient { expectSuccess = false // this way, it does not throw exceptions on != 200 responses. } -fun serverMain(dbName: String, host: String, port: Int) { - execThrowableOrTerminate { - dbCreateTables(dbName) - } +fun serverMain(host: String, port: Int) { val server = embeddedServer(Netty, port = port, host = host) { install(CallLogging) { this.level = Level.DEBUG |