diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/model/Explorer.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/model/Explorer.kt index 7c3fafd435..0c13db4d50 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/model/Explorer.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/model/Explorer.kt @@ -10,7 +10,16 @@ class Explorer(val explorerController: ExplorerController) : AutoCloseable { private var process: Process? = null fun open(config: NodeConfig, onExit: (NodeConfig) -> Unit) { + val explorerDir = config.explorerDir.toFile() + + if (!explorerDir.mkdirs()) { + log.warn("Failed to create working directory '{}'", explorerDir.getAbsolutePath()) + onExit(config) + return + } + val p = explorerController.execute( + config.explorerDir, "--host=localhost", "--port=${config.artemisPort}", "--username=${config.user["user"]}", @@ -35,4 +44,4 @@ class Explorer(val explorerController: ExplorerController) : AutoCloseable { process?.destroy() } -} \ No newline at end of file +} diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/model/ExplorerController.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/model/ExplorerController.kt index 89b9053fcf..a48ca08e0f 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/model/ExplorerController.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/model/ExplorerController.kt @@ -1,6 +1,7 @@ package net.corda.demobench.model import tornadofx.Controller +import java.nio.file.Path import java.nio.file.Paths class ExplorerController : Controller() { @@ -12,7 +13,7 @@ class ExplorerController : Controller() { log.info("Explorer JAR: " + explorerPath) } - internal fun execute(vararg args: String) = jvm.execute(explorerPath, *args) + internal fun execute(cwd: Path, vararg args: String) = jvm.execute(explorerPath, cwd, *args) fun explorer() = Explorer(this) diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/model/JVMConfig.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/model/JVMConfig.kt index 7bac668d1c..6aec7d56ea 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/model/JVMConfig.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/model/JVMConfig.kt @@ -18,8 +18,8 @@ class JVMConfig : Controller() { return arrayOf(javaPath.toString(), "-jar", jarPath.toString(), *args) } - fun execute(jarPath: Path, vararg args: String): Process { - return Runtime.getRuntime().exec(commandFor(jarPath, *args)) + fun execute(jarPath: Path, cwd: Path, vararg args: String): Process { + return Runtime.getRuntime().exec(commandFor(jarPath, *args), null, cwd.toFile()) } } diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeConfig.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeConfig.kt index 35ae18e401..4600b57aa5 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeConfig.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeConfig.kt @@ -19,6 +19,7 @@ class NodeConfig( ) : NetworkMapConfig(legalName, artemisPort) { val nodeDir: Path = baseDir.resolve(key) + val explorerDir: Path = baseDir.resolve("$key-explorer") val user: Map = mapOf( "user" to "guest",