mirror of
https://github.com/corda/corda.git
synced 2025-06-18 07:08:15 +00:00
Added webserver to runnodes.
This commit is contained in:
committed by
Clinton Alexander
parent
13551a6b23
commit
3482452c8b
@ -80,7 +80,11 @@ 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("Starting as webserver: ${cmdlineOptions.isWebserver}")
|
||||
if(cmdlineOptions.isWebserver) {
|
||||
log.info("Starting as webserver on ${conf.webAddress}")
|
||||
} else {
|
||||
log.info("Starting as node on ${conf.artemisAddress}")
|
||||
}
|
||||
|
||||
try {
|
||||
cmdlineOptions.baseDirectory.createDirectories()
|
||||
|
@ -17,7 +17,7 @@ import net.corda.core.utilities.loggerFor
|
||||
import net.corda.node.services.User
|
||||
import net.corda.node.services.config.ConfigHelper
|
||||
import net.corda.node.services.config.FullNodeConfiguration
|
||||
import net.corda.node.services.config.NodeSSLConfiguration
|
||||
import net.corda.node.services.config.SSLConfiguration
|
||||
import net.corda.node.services.messaging.ArtemisMessagingComponent
|
||||
import net.corda.node.services.messaging.CordaRPCClient
|
||||
import net.corda.node.services.messaging.NodeMessagingClient
|
||||
@ -327,7 +327,7 @@ open class DriverDSL(
|
||||
executorService.shutdown()
|
||||
}
|
||||
|
||||
private fun queryNodeInfo(nodeAddress: HostAndPort, sslConfig: NodeSSLConfiguration): NodeInfo? {
|
||||
private fun queryNodeInfo(nodeAddress: HostAndPort, sslConfig: SSLConfiguration): NodeInfo? {
|
||||
var retries = 0
|
||||
while (retries < 5) try {
|
||||
val client = CordaRPCClient(nodeAddress, sslConfig)
|
||||
@ -335,7 +335,7 @@ open class DriverDSL(
|
||||
val rpcOps = client.proxy(timeout = Duration.of(15, ChronoUnit.SECONDS))
|
||||
return rpcOps.nodeIdentity()
|
||||
} catch(e: Exception) {
|
||||
log.debug("Retrying query node info at $nodeAddress")
|
||||
log.error("Retrying query node info at $nodeAddress")
|
||||
retries++
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
customServices.addAll(buildPluginServices(tokenizableServices))
|
||||
|
||||
val uploaders: List<FileUploader> = listOf(storageServices.first.attachments as NodeAttachmentService) +
|
||||
customServices.filter { it is AcceptsFileUpload }.map { it as AcceptsFileUpload }
|
||||
customServices.filterIsInstance(AcceptsFileUpload::class.java)
|
||||
(storage as StorageServiceImpl).initUploaders(uploaders)
|
||||
|
||||
// TODO: uniquenessProvider creation should be inside makeNotaryService(), but notary service initialisation
|
||||
|
@ -78,10 +78,6 @@ class CordaRPCOpsImpl(
|
||||
return services.myInfo
|
||||
}
|
||||
|
||||
override fun ready(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun addVaultTransactionNote(txnId: SecureHash, txnNote: String) {
|
||||
return databaseTransaction(database) {
|
||||
services.vaultService.addNoteToTransaction(txnId, txnNote)
|
||||
|
@ -30,7 +30,6 @@ 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
|
||||
}
|
||||
|
||||
@ -39,7 +38,7 @@ class WebServer(val config: FullNodeConfiguration) {
|
||||
|
||||
fun start() {
|
||||
printBasicNodeInfo("Starting as webserver: ${config.webAddress}")
|
||||
server = initWebServer(connectLocalRpcWithRetries(maxRetries))
|
||||
server = initWebServer(retryConnectLocalRpc())
|
||||
}
|
||||
|
||||
fun run() {
|
||||
@ -78,10 +77,10 @@ class WebServer(val config: FullNodeConfiguration) {
|
||||
httpsConfiguration.outputBufferSize = 32768
|
||||
httpsConfiguration.addCustomizer(SecureRequestCustomizer())
|
||||
val sslContextFactory = SslContextFactory()
|
||||
sslContextFactory.keyStorePath = config.keyStorePath.toString()
|
||||
sslContextFactory.keyStorePath = config.keyStoreFile.toString()
|
||||
sslContextFactory.setKeyStorePassword(config.keyStorePassword)
|
||||
sslContextFactory.setKeyManagerPassword(config.keyStorePassword)
|
||||
sslContextFactory.setTrustStorePath(config.trustStorePath.toString())
|
||||
sslContextFactory.setTrustStorePath(config.trustStoreFile.toString())
|
||||
sslContextFactory.setTrustStorePassword(config.trustStorePassword)
|
||||
sslContextFactory.setExcludeProtocols("SSL.*", "TLSv1", "TLSv1.1")
|
||||
sslContextFactory.setIncludeProtocols("TLSv1.2")
|
||||
@ -153,20 +152,15 @@ class WebServer(val config: FullNodeConfiguration) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun connectLocalRpcWithRetries(retries: Int): CordaRPCOps {
|
||||
for(i in 0..retries - 1) {
|
||||
private fun retryConnectLocalRpc(): CordaRPCOps {
|
||||
while(true) {
|
||||
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()
|
||||
return connectLocalRpcAsNodeUser()
|
||||
} catch (e: ActiveMQNotConnectedException) {
|
||||
log.debug("Could not connect to ${config.artemisAddress} due to exception: ", e)
|
||||
Thread.sleep(retryDelay)
|
||||
}
|
||||
}
|
||||
|
||||
return connectLocalRpcAsNodeUser()
|
||||
}
|
||||
|
||||
private fun connectLocalRpcAsNodeUser(): CordaRPCOps {
|
||||
|
@ -12,12 +12,11 @@ class APIServerImpl(val rpcOps: CordaRPCOps) : APIServer {
|
||||
return LocalDateTime.ofInstant(rpcOps.currentNodeTime(), ZoneId.of("UTC"))
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint is for polling if the webserver is serving. It will always return 200.
|
||||
*/
|
||||
override fun status(): Response {
|
||||
return if (rpcOps.ready()) {
|
||||
Response.ok("started").build()
|
||||
} else {
|
||||
Response.status(Response.Status.SERVICE_UNAVAILABLE).entity("not started").build()
|
||||
}
|
||||
return Response.ok("started").build()
|
||||
}
|
||||
|
||||
override fun info() = rpcOps.nodeIdentity()
|
||||
|
Reference in New Issue
Block a user