libeufin

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

commit 6a5cb8787cd341566af49c6514ccc90dce186691
parent 5a5da42eb8bed68e1aa1ca00a9484bb6717edcfd
Author: Antoine A <>
Date:   Thu, 15 Feb 2024 15:24:15 +0100

Reduce db logging and serve on localhost by default

Diffstat:
Mbank/src/main/kotlin/tech/libeufin/bank/Config.kt | 4++--
Mbank/src/main/kotlin/tech/libeufin/bank/Main.kt | 8+-------
Mcommon/src/main/kotlin/DB.kt | 9++++-----
Mcontrib/bank.conf | 3+++
4 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Config.kt b/bank/src/main/kotlin/tech/libeufin/bank/Config.kt @@ -65,7 +65,7 @@ data class ConversionRate ( sealed interface ServerConfig { data class Unix(val path: String, val mode: Int): ServerConfig - data class Tcp(val port: Int): ServerConfig + data class Tcp(val addr: String, val port: Int): ServerConfig } fun talerConfig(configPath: Path?): TalerConfig = BANK_CONFIG_SOURCE.fromFile(configPath) @@ -79,7 +79,7 @@ fun TalerConfig.loadDbConfig(): DatabaseConfig { fun TalerConfig.loadServerConfig(): ServerConfig { return when (val method = requireString("libeufin-bank", "serve")) { - "tcp" -> ServerConfig.Tcp(requireNumber("libeufin-bank", "port")) + "tcp" -> ServerConfig.Tcp(requireString("libeufin-bank", "address"), requireNumber("libeufin-bank", "port")) "unix" -> ServerConfig.Unix(requireString("libeufin-bank", "unixpath"), requireNumber("libeufin-bank", "unixpath_mode")) else -> throw TalerConfigError.invalid("server method", "libeufin-bank", "serve", "expected 'tcp' or 'unix' got '$method'") } diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt @@ -308,6 +308,7 @@ class ServeBank : CliktCommand("Run libeufin-bank HTTP server", name = "serve") when (serverCfg) { is ServerConfig.Tcp -> { port = serverCfg.port + host = serverCfg.addr } is ServerConfig.Unix -> throw Exception("Can only serve libeufin-bank via TCP") @@ -317,13 +318,6 @@ class ServeBank : CliktCommand("Run libeufin-bank HTTP server", name = "serve") } val local = embeddedServer(Netty, env) engine = local - when (serverCfg) { - is ServerConfig.Tcp -> { - logger.info("Server listening on http://localhost:${serverCfg.port}") - } - is ServerConfig.Unix -> - throw Exception("Can only serve libeufin-bank via TCP") - } local.start(wait = true) } } diff --git a/common/src/main/kotlin/DB.kt b/common/src/main/kotlin/DB.kt @@ -58,7 +58,6 @@ fun getJdbcConnectionFromPg(pgConn: String): String { return pgConn } if (!pgConn.startsWith("postgresql://") && !pgConn.startsWith("postgres://")) { - logger.info("Not a Postgres connection string: $pgConn") throw Exception("Not a Postgres connection string: $pgConn") } var maybeUnixSocket = false @@ -110,7 +109,7 @@ data class DatabaseConfig( fun pgDataSource(dbConfig: String): PGSimpleDataSource { val jdbcConnStr = getJdbcConnectionFromPg(dbConfig) - logger.info("connecting to database via JDBC string '$jdbcConnStr'") + logger.debug("connecting to database via JDBC string '$jdbcConnStr'") val pgSource = PGSimpleDataSource() pgSource.setUrl(jdbcConnStr) pgSource.prepareThreshold = 1 @@ -244,13 +243,13 @@ fun initializeDatabaseTables(conn: PgConnection, cfg: DatabaseConfig, sqlFilePre checkStmt.setString(1, patchName) val patchCount = checkStmt.oneOrNull { it.getInt(1) } ?: throw Exception("unable to query patches") if (patchCount >= 1) { - logger.info("patch $patchName already applied") + logger.debug("patch $patchName already applied") continue } val path = Path("${cfg.sqlDir}/$sqlFilePrefix-$numStr.sql") if (!path.exists()) { - logger.info("path $path doesn't exist anymore, stopping") + logger.debug("path $path doesn't exist anymore, stopping") break } logger.info("applying patch $path") @@ -259,7 +258,7 @@ fun initializeDatabaseTables(conn: PgConnection, cfg: DatabaseConfig, sqlFilePre } val sqlProcedures = Path("${cfg.sqlDir}/$sqlFilePrefix-procedures.sql") if (!sqlProcedures.exists()) { - logger.info("no procedures.sql for the SQL collection: $sqlFilePrefix") + logger.warn("no procedures.sql for the SQL collection: $sqlFilePrefix") return@transaction } logger.info("run procedure.sql") diff --git a/contrib/bank.conf b/contrib/bank.conf @@ -48,6 +48,9 @@ SERVE = tcp # Port on which the HTTP server listens, e.g. 9967. Only used if SERVE is tcp. PORT = 8080 +# Address on which the HTTP server listens, e.g. localhost. Only used if SERVE is tcp. +ADDRESS = localhost + # Which unix domain path should we bind to? Only used if SERVE is unix. # UNIXPATH = libeufin-bank.sock