diff options
author | MS <ms@taler.net> | 2021-01-27 13:36:15 +0100 |
---|---|---|
committer | MS <ms@taler.net> | 2021-01-27 13:36:15 +0100 |
commit | c8d3cdeeb92ed054e77c3c549f17e99fa5f288aa (patch) | |
tree | 3b6d9dd66df8210d0416f4070b8defd7c5fbff53 /nexus | |
parent | 90d2a60ddca12cfb819c40564ef2f3d17344d047 (diff) | |
download | libeufin-c8d3cdeeb92ed054e77c3c549f17e99fa5f288aa.tar.gz libeufin-c8d3cdeeb92ed054e77c3c549f17e99fa5f288aa.tar.bz2 libeufin-c8d3cdeeb92ed054e77c3c549f17e99fa5f288aa.zip |
db connection string only from env
Diffstat (limited to 'nexus')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt index 27638c99..81ed7871 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -35,15 +35,11 @@ import execThrowableOrTerminate import com.github.ajalt.clikt.core.* import com.github.ajalt.clikt.parameters.options.versionOption import tech.libeufin.nexus.iso20022.parseCamtMessage -import tech.libeufin.util.XMLUtil -import tech.libeufin.util.getVersion -import tech.libeufin.util.setLogLevel +import tech.libeufin.util.* import java.io.File val logger: Logger = LoggerFactory.getLogger("tech.libeufin.nexus") - -val LIBEUFIN_NEXUS_DB_CONNECTION = System.getenv( - "LIBEUFIN_NEXUS_DB_CONNECTION") ?: "jdbc:sqlite:/tmp/libeufin-nexus.sqlite3" +val NEXUS_DB_ENV_VAR_NAME = "LIBEUFIN_NEXUS_DB_CONNECTION" class NexusCommand : CliktCommand() { init { @@ -58,13 +54,12 @@ class Serve : CliktCommand("Run nexus HTTP server") { helpFormatter = CliktHelpFormatter(showDefaultValues = true) } } - private val dbConnString by option().default(LIBEUFIN_NEXUS_DB_CONNECTION) private val host by option().default("127.0.0.1") private val port by option().int().default(5001) private val logLevel by option() override fun run() { setLogLevel(logLevel) - serverMain(dbConnString, host, port) + serverMain(getDbConnFromEnv(NEXUS_DB_ENV_VAR_NAME), host, port) } } @@ -85,8 +80,8 @@ class ResetTables : CliktCommand("Drop all the tables from the database") { helpFormatter = CliktHelpFormatter(showDefaultValues = true) } } - private val dbConnString by option().default(LIBEUFIN_NEXUS_DB_CONNECTION) override fun run() { + val dbConnString = getDbConnFromEnv(NEXUS_DB_ENV_VAR_NAME) execThrowableOrTerminate { dbDropTables(dbConnString) dbCreateTables(dbConnString) @@ -95,12 +90,11 @@ class ResetTables : CliktCommand("Drop all the tables from the database") { } class Superuser : CliktCommand("Add superuser or change pw") { - private val dbConnString by option().default(LIBEUFIN_NEXUS_DB_CONNECTION) private val username by argument() private val password by option().prompt(requireConfirmation = true, hideInput = true) override fun run() { execThrowableOrTerminate { - dbCreateTables(dbConnString) + dbCreateTables(getDbConnFromEnv(NEXUS_DB_ENV_VAR_NAME)) } transaction { val hashedPw = hashpw(password) |