diff options
author | Antoine A <> | 2024-05-01 13:47:06 +0900 |
---|---|---|
committer | Antoine A <> | 2024-05-01 13:47:06 +0900 |
commit | a09b84c636f6332b219480ca620060eb6ca13758 (patch) | |
tree | 45c12f894b4297215814ada6d3aa3e43d9f2fdd3 /nexus/src/main | |
parent | 15ab519ed54c0d5ca5840c175f9aa0642a6ccf87 (diff) | |
download | libeufin-a09b84c636f6332b219480ca620060eb6ca13758.tar.gz libeufin-a09b84c636f6332b219480ca620060eb6ca13758.tar.bz2 libeufin-a09b84c636f6332b219480ca620060eb6ca13758.zip |
nexus: add libeufin-nexus-httpd service
Diffstat (limited to 'nexus/src/main')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt index c8b46008..b301f555 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -27,6 +27,7 @@ package tech.libeufin.nexus import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.subcommands +import com.github.ajalt.clikt.core.ProgramResult import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.convert import com.github.ajalt.clikt.parameters.groups.provideDelegate @@ -148,9 +149,32 @@ class InitiatePayment: CliktCommand("Initiate an outgoing payment") { class Serve : CliktCommand("Run libeufin-nexus HTTP server", name = "serve") { private val common by CommonOption() + private val check by option().flag() override fun run() = cliCmd(logger, common.log) { val cfg = loadNexusConfig(common.config) + + if (check) { + // Check if the server is to be started + val apis = listOf( + cfg.wireGatewayApiCfg to "Wire Gateway API", + cfg.revenueApiCfg to "Revenue API" + ) + var startServer = false + for ((api, name) in apis) { + if (api != null) { + startServer = true + logger.info("$name is enabled: starting the server") + } + } + if (!startServer) { + logger.info("All APIs are disabled: not starting the server") + throw ProgramResult(1) + } else { + throw ProgramResult(0) + } + } + val dbCfg = cfg.config.dbConfig() val serverCfg = cfg.config.loadServerConfig("nexus-httpd") Database(dbCfg, cfg.currency).use { db -> |