mirror of
https://github.com/corda/corda.git
synced 2024-12-21 22:07:55 +00:00
node-driver: Make debugging optional and off by default
This commit is contained in:
parent
9d22d66548
commit
1a2c712a48
@ -120,6 +120,7 @@ sealed class PortAllocation {
|
|||||||
* and may be specified in [DriverDSL.startNode].
|
* and may be specified in [DriverDSL.startNode].
|
||||||
* @param portAllocation The port allocation strategy to use for the messaging and the web server addresses. Defaults to incremental.
|
* @param portAllocation The port allocation strategy to use for the messaging and the web server addresses. Defaults to incremental.
|
||||||
* @param debugPortAllocation The port allocation strategy to use for jvm debugging. Defaults to incremental.
|
* @param debugPortAllocation The port allocation strategy to use for jvm debugging. Defaults to incremental.
|
||||||
|
* @param isDebug Indicates whether the spawned nodes should start in jdwt debug mode.
|
||||||
* @param dsl The dsl itself.
|
* @param dsl The dsl itself.
|
||||||
* @return The value returned in the [dsl] closure.
|
* @return The value returned in the [dsl] closure.
|
||||||
*/
|
*/
|
||||||
@ -127,12 +128,14 @@ fun <A> driver(
|
|||||||
baseDirectory: String = "build/${getTimestampAsDirectoryName()}",
|
baseDirectory: String = "build/${getTimestampAsDirectoryName()}",
|
||||||
portAllocation: PortAllocation = PortAllocation.Incremental(10000),
|
portAllocation: PortAllocation = PortAllocation.Incremental(10000),
|
||||||
debugPortAllocation: PortAllocation = PortAllocation.Incremental(5005),
|
debugPortAllocation: PortAllocation = PortAllocation.Incremental(5005),
|
||||||
|
isDebug: Boolean = false,
|
||||||
dsl: DriverDSLExposedInterface.() -> A
|
dsl: DriverDSLExposedInterface.() -> A
|
||||||
) = genericDriver(
|
) = genericDriver(
|
||||||
driverDsl = DriverDSL(
|
driverDsl = DriverDSL(
|
||||||
portAllocation = portAllocation,
|
portAllocation = portAllocation,
|
||||||
debugPortAllocation = debugPortAllocation,
|
debugPortAllocation = debugPortAllocation,
|
||||||
baseDirectory = baseDirectory
|
baseDirectory = baseDirectory,
|
||||||
|
isDebug = isDebug
|
||||||
),
|
),
|
||||||
coerce = { it },
|
coerce = { it },
|
||||||
dsl = dsl
|
dsl = dsl
|
||||||
@ -214,7 +217,8 @@ fun <A> poll(pollName: String, pollIntervalMs: Long = 500, warnCount: Int = 120,
|
|||||||
class DriverDSL(
|
class DriverDSL(
|
||||||
val portAllocation: PortAllocation,
|
val portAllocation: PortAllocation,
|
||||||
val debugPortAllocation: PortAllocation,
|
val debugPortAllocation: PortAllocation,
|
||||||
val baseDirectory: String
|
val baseDirectory: String,
|
||||||
|
val isDebug: Boolean
|
||||||
) : DriverDSLInternalInterface {
|
) : DriverDSLInternalInterface {
|
||||||
override val networkMapCache = InMemoryNetworkMapCache()
|
override val networkMapCache = InMemoryNetworkMapCache()
|
||||||
private val networkMapName = "NetworkMapService"
|
private val networkMapName = "NetworkMapService"
|
||||||
@ -280,7 +284,7 @@ class DriverDSL(
|
|||||||
override fun startNode(providedName: String?, advertisedServices: Set<ServiceType>): Future<NodeInfo> {
|
override fun startNode(providedName: String?, advertisedServices: Set<ServiceType>): Future<NodeInfo> {
|
||||||
val messagingAddress = portAllocation.nextHostAndPort()
|
val messagingAddress = portAllocation.nextHostAndPort()
|
||||||
val apiAddress = portAllocation.nextHostAndPort()
|
val apiAddress = portAllocation.nextHostAndPort()
|
||||||
val debugPort = debugPortAllocation.nextPort()
|
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
|
||||||
val name = providedName ?: "${pickA(name)}-${messagingAddress.port}"
|
val name = providedName ?: "${pickA(name)}-${messagingAddress.port}"
|
||||||
|
|
||||||
val nodeDirectory = "$baseDirectory/$name"
|
val nodeDirectory = "$baseDirectory/$name"
|
||||||
@ -403,7 +407,7 @@ class DriverDSL(
|
|||||||
|
|
||||||
private fun startNetworkMapService() {
|
private fun startNetworkMapService() {
|
||||||
val apiAddress = portAllocation.nextHostAndPort()
|
val apiAddress = portAllocation.nextHostAndPort()
|
||||||
val debugPort = debugPortAllocation.nextPort()
|
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
|
||||||
|
|
||||||
val nodeDirectory = "$baseDirectory/$networkMapName"
|
val nodeDirectory = "$baseDirectory/$networkMapName"
|
||||||
|
|
||||||
@ -443,7 +447,7 @@ class DriverDSL(
|
|||||||
cliParams: NodeRunner.CliParams,
|
cliParams: NodeRunner.CliParams,
|
||||||
legalName: String,
|
legalName: String,
|
||||||
quasarJarPath: String,
|
quasarJarPath: String,
|
||||||
debugPort: Int
|
debugPort: Int?
|
||||||
): Process {
|
): Process {
|
||||||
|
|
||||||
// Write node.conf
|
// Write node.conf
|
||||||
@ -455,9 +459,12 @@ class DriverDSL(
|
|||||||
val path = System.getProperty("java.home") + separator + "bin" + separator + "java"
|
val path = System.getProperty("java.home") + separator + "bin" + separator + "java"
|
||||||
val javaArgs = listOf(path) +
|
val javaArgs = listOf(path) +
|
||||||
listOf("-Dname=$legalName", "-javaagent:$quasarJarPath",
|
listOf("-Dname=$legalName", "-javaagent:$quasarJarPath",
|
||||||
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$debugPort",
|
|
||||||
"-cp", classpath, className) +
|
"-cp", classpath, className) +
|
||||||
cliParams.toCliArguments()
|
cliParams.toCliArguments() +
|
||||||
|
if (debugPort != null)
|
||||||
|
listOf("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$debugPort")
|
||||||
|
else
|
||||||
|
listOf()
|
||||||
val builder = ProcessBuilder(javaArgs)
|
val builder = ProcessBuilder(javaArgs)
|
||||||
builder.redirectError(Paths.get("error.$className.log").toFile())
|
builder.redirectError(Paths.get("error.$className.log").toFile())
|
||||||
builder.inheritIO()
|
builder.inheritIO()
|
||||||
|
Loading…
Reference in New Issue
Block a user