mirror of
https://github.com/corda/corda.git
synced 2025-01-18 18:56:28 +00:00
Fixed logging to log file for webserver at startup. Removed more redundant config.
This commit is contained in:
parent
5d8217bbc7
commit
e3872c1469
@ -43,6 +43,10 @@ dependencies {
|
||||
compile "org.jolokia:jolokia-agent-war:$jolokia_version"
|
||||
compile "commons-fileupload:commons-fileupload:$fileupload_version"
|
||||
|
||||
// Log4J: logging framework (with SLF4J bindings)
|
||||
compile "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
|
||||
compile "org.apache.logging.log4j:log4j-core:$log4j_version"
|
||||
|
||||
// JOpt: for command line flags.
|
||||
compile "net.sf.jopt-simple:jopt-simple:$jopt_simple_version"
|
||||
|
||||
|
@ -67,7 +67,7 @@ data class CmdLineOptions(val baseDirectory: Path,
|
||||
allowMissingConfig: Boolean = false,
|
||||
configOverrides: Map<String, Any?> = emptyMap()): Config {
|
||||
val parseOptions = ConfigParseOptions.defaults()
|
||||
val defaultConfig = ConfigFactory.parseResources("reference.conf", parseOptions.setAllowMissing(false))
|
||||
val defaultConfig = ConfigFactory.parseResources("web-reference.conf", parseOptions.setAllowMissing(false))
|
||||
val appConfig = ConfigFactory.parseFile(configFile.toFile(), parseOptions.setAllowMissing(allowMissingConfig))
|
||||
val overrideConfig = ConfigFactory.parseMap(configOverrides + mapOf(
|
||||
// Add substitution values here
|
||||
|
@ -16,19 +16,8 @@ class WebServerConfig(val baseDirectory: Path, val config: Config) : SSLConfigur
|
||||
override val certificatesDirectory: Path get() = baseDirectory / "certificates"
|
||||
override val keyStorePassword: String by config
|
||||
override val trustStorePassword: String by config
|
||||
val myLegalName: String by config
|
||||
val exportJMXto: String get() = "http"
|
||||
val rpcUsers: List<User> = config
|
||||
.getListOrElse<Config>("rpcUsers") { emptyList() }
|
||||
.map {
|
||||
val username = it.getString("user")
|
||||
require(username.matches("\\w+".toRegex())) { "Username $username contains invalid characters" }
|
||||
val password = it.getString("password")
|
||||
val permissions = it.getListOrElse<String>("permissions") { emptyList() }.toSet()
|
||||
User(username, password, permissions)
|
||||
}
|
||||
val useHTTPS: Boolean by config
|
||||
val p2pAddress: HostAndPort by config
|
||||
val rpcAddress: HostAndPort? by config
|
||||
val p2pAddress: HostAndPort by config // TODO: Use RPC port instead of P2P port (RPC requires authentication, P2P does not)
|
||||
val webAddress: HostAndPort by config
|
||||
}
|
@ -21,6 +21,7 @@ import org.eclipse.jetty.webapp.WebAppContext
|
||||
import org.glassfish.jersey.server.ResourceConfig
|
||||
import org.glassfish.jersey.server.ServerProperties
|
||||
import org.glassfish.jersey.servlet.ServletContainer
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.util.*
|
||||
|
||||
@ -31,10 +32,11 @@ class NodeWebServer(val config: WebServerConfig) {
|
||||
}
|
||||
|
||||
val address = config.webAddress
|
||||
private var renderBasicInfoToConsole = true
|
||||
private lateinit var server: Server
|
||||
|
||||
fun start() {
|
||||
println("Starting as webserver: ${config.webAddress}")
|
||||
logAndMaybePrint("Starting as webserver: ${config.webAddress}")
|
||||
server = initWebServer(retryConnectLocalRpc())
|
||||
}
|
||||
|
||||
@ -174,4 +176,11 @@ class NodeWebServer(val config: WebServerConfig) {
|
||||
val pluginRegistries: List<CordaPluginRegistry> by lazy {
|
||||
ServiceLoader.load(CordaPluginRegistry::class.java).toList()
|
||||
}
|
||||
|
||||
/** Used for useful info that we always want to show, even when not logging to the console */
|
||||
fun logAndMaybePrint(description: String, info: String? = null) {
|
||||
val msg = if (info == null) description else "${description.padEnd(40)}: $info"
|
||||
val loggerName = if (renderBasicInfoToConsole) "BasicInfo" else "Main"
|
||||
LoggerFactory.getLogger(loggerName).info(msg)
|
||||
}
|
||||
}
|
||||
|
1
client/webserver/src/main/resources/web-reference.conf
Normal file
1
client/webserver/src/main/resources/web-reference.conf
Normal file
@ -0,0 +1 @@
|
||||
useHTTPS = false
|
Loading…
Reference in New Issue
Block a user