mirror of
https://github.com/corda/corda.git
synced 2024-12-21 13:57:54 +00:00
Runnodes now works with the new separate webserver.
This commit is contained in:
parent
537ffae113
commit
13551a6b23
@ -145,7 +145,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build']) {
|
||||
nearestCity "London"
|
||||
advertisedServices = ["corda.notary.validating"]
|
||||
artemisPort 10002
|
||||
webPort 10003
|
||||
cordapps = []
|
||||
}
|
||||
node {
|
||||
|
@ -69,6 +69,10 @@ task buildCordaJAR(type: FatCapsule, dependsOn: ['buildCertSigningRequestUtility
|
||||
// If you change these flags, please also update Driver.kt
|
||||
jvmArgs = ['-Xmx200m', '-XX:+UseG1GC']
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes('Corda-Version': corda_version)
|
||||
}
|
||||
}
|
||||
|
||||
task buildCertSigningRequestUtilityJAR(type: FatCapsule) {
|
||||
|
@ -58,7 +58,8 @@ fun main(args: Array<String>) {
|
||||
|
||||
drawBanner()
|
||||
|
||||
System.setProperty("log-path", (cmdlineOptions.baseDirectory / "logs").toString())
|
||||
val logDir = if (cmdlineOptions.isWebserver) "logs/web" else "logs"
|
||||
System.setProperty("log-path", (cmdlineOptions.baseDirectory / logDir).toString())
|
||||
|
||||
val log = LoggerFactory.getLogger("Main")
|
||||
printBasicNodeInfo("Logs can be found in", System.getProperty("log-path"))
|
||||
@ -79,7 +80,7 @@ fun main(args: Array<String>) {
|
||||
log.info("VM ${info.vmName} ${info.vmVendor} ${info.vmVersion}")
|
||||
log.info("Machine: ${InetAddress.getLocalHost().hostName}")
|
||||
log.info("Working Directory: ${cmdlineOptions.baseDirectory}")
|
||||
log.info("Started as webserver: ${cmdlineOptions.isWebserver}")
|
||||
log.info("Starting as webserver: ${cmdlineOptions.isWebserver}")
|
||||
|
||||
try {
|
||||
cmdlineOptions.baseDirectory.createDirectories()
|
||||
@ -101,7 +102,11 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
node.run()
|
||||
} else {
|
||||
WebServer(conf).start()
|
||||
val server = WebServer(conf)
|
||||
server.start()
|
||||
val elapsed = (System.currentTimeMillis() - startTime) / 10 / 100.0
|
||||
printBasicNodeInfo("Webserver started up in $elapsed sec")
|
||||
server.run()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
log.error("Exception during node startup", e)
|
||||
|
@ -425,7 +425,7 @@ open class DriverDSL(
|
||||
}
|
||||
val url = URL(protocol + configuration.webAddress.toString() + "/api/status")
|
||||
val client = OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS).readTimeout(60, TimeUnit.SECONDS).build()
|
||||
val retries = 5
|
||||
val retries = 50
|
||||
|
||||
for (i in 0..retries) {
|
||||
try {
|
||||
@ -456,7 +456,6 @@ open class DriverDSL(
|
||||
}
|
||||
|
||||
private fun startNetworkMapService(): ListenableFuture<Process> {
|
||||
val apiAddress = portAllocation.nextHostAndPort()
|
||||
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
|
||||
|
||||
val baseDirectory = driverDirectory / networkMapLegalName
|
||||
|
@ -3,6 +3,7 @@ package net.corda.node.webserver
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.node.CordaPluginRegistry
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import net.corda.node.printBasicNodeInfo
|
||||
import net.corda.node.services.config.FullNodeConfiguration
|
||||
import net.corda.node.services.messaging.ArtemisMessagingComponent
|
||||
import net.corda.node.services.messaging.CordaRPCClient
|
||||
@ -11,6 +12,7 @@ import net.corda.node.webserver.servlets.ObjectMapperConfig
|
||||
import net.corda.node.webserver.servlets.DataUploadServlet
|
||||
import net.corda.node.webserver.servlets.ResponseFilter
|
||||
import net.corda.node.webserver.internal.APIServerImpl
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException
|
||||
import org.eclipse.jetty.server.*
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection
|
||||
import org.eclipse.jetty.servlet.DefaultServlet
|
||||
@ -28,12 +30,19 @@ import java.util.*
|
||||
class WebServer(val config: FullNodeConfiguration) {
|
||||
private companion object {
|
||||
val log = loggerFor<WebServer>()
|
||||
val maxRetries = 60 // TODO: Make configurable
|
||||
val retryDelay = 1000L // Milliseconds
|
||||
}
|
||||
|
||||
val address = config.webAddress
|
||||
private lateinit var server: Server
|
||||
|
||||
fun start() {
|
||||
val server = initWebServer(connectLocalRpcAsNodeUser())
|
||||
printBasicNodeInfo("Starting as webserver: ${config.webAddress}")
|
||||
server = initWebServer(connectLocalRpcWithRetries(maxRetries))
|
||||
}
|
||||
|
||||
fun run() {
|
||||
while(server.isRunning) {
|
||||
Thread.sleep(100) // TODO: Redesign
|
||||
}
|
||||
@ -85,7 +94,7 @@ class WebServer(val config: FullNodeConfiguration) {
|
||||
val httpConfiguration = HttpConfiguration()
|
||||
httpConfiguration.outputBufferSize = 32768
|
||||
val httpConnector = ServerConnector(server, HttpConnectionFactory(httpConfiguration))
|
||||
println("Starting webserver on address $address")
|
||||
log.info("Starting webserver on address $address")
|
||||
httpConnector.port = address.port
|
||||
httpConnector
|
||||
}
|
||||
@ -94,7 +103,7 @@ class WebServer(val config: FullNodeConfiguration) {
|
||||
server.handler = handlerCollection
|
||||
//runOnStop += Runnable { server.stop() }
|
||||
server.start()
|
||||
println("Server started")
|
||||
log.info("Server started")
|
||||
log.info("Embedded web server is listening on", "http://${InetAddress.getLocalHost().hostAddress}:${connector.port}/")
|
||||
return server
|
||||
}
|
||||
@ -144,6 +153,22 @@ class WebServer(val config: FullNodeConfiguration) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun connectLocalRpcWithRetries(retries: Int): CordaRPCOps {
|
||||
for(i in 0..retries - 1) {
|
||||
try {
|
||||
log.info("Connecting to node at ${config.artemisAddress} as node user")
|
||||
val client = CordaRPCClient(config.artemisAddress, config)
|
||||
client.start(ArtemisMessagingComponent.NODE_USER, ArtemisMessagingComponent.NODE_USER)
|
||||
return client.proxy()
|
||||
} catch (e: ActiveMQNotConnectedException) {
|
||||
log.debug("Could not connect to ${config.artemisAddress} due to exception: ", e)
|
||||
Thread.sleep(retryDelay)
|
||||
}
|
||||
}
|
||||
|
||||
return connectLocalRpcAsNodeUser()
|
||||
}
|
||||
|
||||
private fun connectLocalRpcAsNodeUser(): CordaRPCOps {
|
||||
log.info("Connecting to node at ${config.artemisAddress} as node user")
|
||||
val client = CordaRPCClient(config.artemisAddress, config)
|
||||
|
@ -1 +1 @@
|
||||
gradlePluginsVersion=0.7
|
||||
gradlePluginsVersion=0.7.1
|
||||
|
Loading…
Reference in New Issue
Block a user