libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 4b9a85aeb7cc1d5f279304ea57b558ae7ba3366e
parent dee223922daacb357e79b711db568f97d85bb9e0
Author: Florian Dold <florian@dold.me>
Date:   Fri, 22 Sep 2023 18:20:06 +0200

load port from config file

Diffstat:
Mbank/src/main/kotlin/tech/libeufin/bank/Main.kt | 9++++++++-
Acontrib/libeufin-bank.sample.conf | 13+++++++++++++
Mutil/src/main/kotlin/TalerConfig.kt | 8++++++++
3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt @@ -420,10 +420,17 @@ class ServeBank : CliktCommand("Run libeufin-bank HTTP server", name = "serve") val ctx = readBankApplicationContextFromConfig(config) val dbConnStr = config.requireValueString("libeufin-bank-db-postgres", "config") logger.info("using database '$dbConnStr'") + val serveMethod = config.requireValueString("libeufin-bank", "serve") + if (serveMethod.lowercase() != "tcp") { + logger.info("Can only serve libeufin-bank via TCP") + exitProcess(1) + } + val servePortLong = config.requireValueNumber("libeufin-bank", "port") + val servePort = servePortLong.toInt() val db = Database(dbConnStr, ctx.currency) if (!maybeCreateAdminAccount(db, ctx)) // logs provided by the helper exitProcess(1) - embeddedServer(Netty, port = 8080) { + embeddedServer(Netty, port = servePort) { corebankWebApp(db, ctx) }.start(wait = true) } diff --git a/contrib/libeufin-bank.sample.conf b/contrib/libeufin-bank.sample.conf @@ -0,0 +1,13 @@ +[libeufin-bank] +currency = KUDOS +DEFAULT_CUSTOMER_DEBT_LIMIT = KUDOS:200 +DEFAULT_ADMIN_DEBT_LIMIT = KUDOS:2000 +REGISTRATION_BONUS = KUDOS:100 +REGISTRATION_BONUS_ENABLED = yes +MAX_AUTH_TOKEN_DURATION = 1d + +SERVE = tcp +PORT = 8080 + +[libeufin-bank-db-postgres] +CONFIG = postgresql:///libeufinbank diff --git a/util/src/main/kotlin/TalerConfig.kt b/util/src/main/kotlin/TalerConfig.kt @@ -128,6 +128,14 @@ class TalerConfig { return entry.value } + fun requireValueNumber(section: String, option: String): Long { + val entry = lookupEntry(section, option) + if (entry == null) { + throw TalerConfigError("expected string in configuration section $section option $option") + } + return entry.value.toLong(10) + } + fun lookupValueBooleanDefault(section: String, option: String, default: Boolean): Boolean { val entry = lookupEntry(section, option) if (entry == null) {