mirror of
https://github.com/corda/corda.git
synced 2025-01-18 02:39:51 +00:00
CORDA-1288 Node properties can be set as system properties. (#3172)
This commit is contained in:
parent
8990e9f783
commit
fc88cefbc8
@ -301,4 +301,14 @@ path to the node's base directory.
|
||||
:permissions: A list of permissions for starting flows via RPC. To give the user the permission to start the flow
|
||||
``foo.bar.FlowClass``, add the string ``StartFlow.foo.bar.FlowClass`` to the list. If the list
|
||||
contains the string ``ALL``, the user can start any flow via RPC. This value is intended for administrator
|
||||
users and for development.
|
||||
users and for development.
|
||||
|
||||
Fields Override
|
||||
---------------
|
||||
JVM options or environmental variables prefixed ``corda.`` can override ``node.conf`` fields.
|
||||
Provided system properties also can set value for absent fields in ``node.conf``.
|
||||
Example adding/overriding keyStore password when starting Corda node:
|
||||
|
||||
.. sourcecode:: shell
|
||||
|
||||
java -Dcorda.rpcSettings.ssl.keyStorePassword=mypassword -jar node.jar
|
@ -10,6 +10,7 @@ import net.corda.core.internal.div
|
||||
import net.corda.core.internal.exists
|
||||
import net.corda.nodeapi.internal.*
|
||||
import net.corda.nodeapi.internal.config.SSLConfiguration
|
||||
import net.corda.nodeapi.internal.config.toProperties
|
||||
import net.corda.nodeapi.internal.crypto.X509KeyStore
|
||||
import net.corda.nodeapi.internal.crypto.loadKeyStore
|
||||
import net.corda.nodeapi.internal.crypto.save
|
||||
@ -20,6 +21,9 @@ fun configOf(vararg pairs: Pair<String, Any?>): Config = ConfigFactory.parseMap(
|
||||
operator fun Config.plus(overrides: Map<String, Any?>): Config = ConfigFactory.parseMap(overrides).withFallback(this)
|
||||
|
||||
object ConfigHelper {
|
||||
|
||||
private const val CORDA_PROPERTY_PREFIX = "corda."
|
||||
|
||||
private val log = LoggerFactory.getLogger(javaClass)
|
||||
fun loadConfig(baseDirectory: Path,
|
||||
configFile: Path = baseDirectory / "node.conf",
|
||||
@ -33,10 +37,14 @@ object ConfigHelper {
|
||||
val smartDevMode = CordaSystemUtils.isOsMac() || (CordaSystemUtils.isOsWindows() && !CordaSystemUtils.getOsName().toLowerCase().contains("server"))
|
||||
val devModeConfig = ConfigFactory.parseMap(mapOf("devMode" to smartDevMode))
|
||||
|
||||
val systemOverrides = ConfigFactory.systemProperties().cordaEntriesOnly()
|
||||
val environmentOverrides = ConfigFactory.systemEnvironment().cordaEntriesOnly()
|
||||
val finalConfig = configOf(
|
||||
// Add substitution values here
|
||||
"baseDirectory" to baseDirectory.toString())
|
||||
.withFallback(configOverrides)
|
||||
.withFallback(systemOverrides)
|
||||
.withFallback(environmentOverrides)
|
||||
.withFallback(appConfig)
|
||||
.withFallback(devModeConfig) // this needs to be after the appConfig, so it doesn't override the configured devMode
|
||||
.withFallback(defaultConfig)
|
||||
@ -52,6 +60,11 @@ object ConfigHelper {
|
||||
|
||||
return finalConfig
|
||||
}
|
||||
|
||||
private fun Config.cordaEntriesOnly(): Config {
|
||||
|
||||
return ConfigFactory.parseMap(toProperties().filterKeys { (it as String).startsWith(CORDA_PROPERTY_PREFIX) }.mapKeys { (it.key as String).removePrefix(CORDA_PROPERTY_PREFIX) })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user