mirror of
https://github.com/corda/corda.git
synced 2024-12-28 00:38:55 +00:00
Ensure that Node Explorer can write into its working directory.
This commit is contained in:
parent
006fd98a51
commit
37aa486bd7
@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<String, Any> = mapOf(
|
||||
"user" to "guest",
|
||||
|
Loading…
Reference in New Issue
Block a user