commit b4b71a4064b6b2e220b5d2cd333ebf9475fcd85d
parent be29b5b4861b56e916b8671ee7a62d69c41523c8
Author: ms <ms@taler.net>
Date: Thu, 25 Mar 2021 10:21:56 +0100
Delaying scheduled tasks detection.
That used to happen before the responsible database
tables got completely created, resulting in many database
errors due to a non existent table.
Diffstat:
2 files changed, 9 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
@@ -34,7 +34,9 @@ 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.*
import java.io.File
@@ -60,6 +62,7 @@ class Serve : CliktCommand("Run nexus HTTP server") {
override fun run() {
setLogLevel(logLevel)
serverMain(getDbConnFromEnv(NEXUS_DB_ENV_VAR_NAME), host, port)
+ startOperationScheduler(client)
}
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -183,13 +183,14 @@ fun requireBankConnection(call: ApplicationCall, parameterKey: String): NexusBan
return requireBankConnectionInternal(name)
}
+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)
}
- val client = HttpClient {
- expectSuccess = false // this way, it does not throw exceptions on != 200 responses.
- }
val server = embeddedServer(Netty, port = port, host = host) {
install(CallLogging) {
this.level = Level.DEBUG
@@ -251,8 +252,6 @@ fun serverMain(dbName: String, host: String, port: Int) {
return@intercept finish()
}
}
-
- startOperationScheduler(client)
routing {
get("/config") {
call.respond(
@@ -1065,4 +1064,4 @@ fun serverMain(dbName: String, host: String, port: Int) {
logger.error(e.message)
exitProcess(1)
}
-}
+}
+\ No newline at end of file