commit 7185215e9e3578127afd95a190ec4290ee591589 parent 0a4f8f53f84ad7e172880e0880a670aa651a01a4 Author: Florian Dold <florian@dold.me> Date: Sat, 7 Aug 2021 13:53:30 +0200 make sure task scheduler is executed Diffstat:
4 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli @@ -802,7 +802,7 @@ def show_payment(obj, account_name, payment_uuid): @accounts.command(help="List payment initiations") @click.argument("account-name") @click.pass_obj -def show_payment(obj, account_name): +def list_payments(obj, account_name): url = urljoin( obj.nexus_base_url, f"/bank-accounts/{account_name}/payment-initiations" ) @@ -813,7 +813,7 @@ def show_payment(obj, account_name): exit(1) tell_user( - resp, + resp, withsuccess=True, ) check_response_status(resp) @@ -822,7 +822,7 @@ def show_payment(obj, account_name): @click.argument("account-name") @click.option("--payment-uuid", help="payment unique identifier", required=True) @click.pass_obj -def show_payment(obj, account_name, payment_uuid): +def delete_payment(obj, account_name, payment_uuid): url = urljoin( obj.nexus_base_url, f"/bank-accounts/{account_name}/payment-initiations/{payment_uuid}", @@ -864,7 +864,7 @@ def fetch_transactions(obj, account_name, range_type, level): check_response_status(resp) -@accounts.command(help="get transactions from the simplified nexus JSON API") +@accounts.command(help="Get transactions from the simplified nexus JSON API") @click.option( "--compact/--no-compact", help="Tells only amount/subject for each payment", 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,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 @@ -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 @@ -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