mirror of
https://github.com/corda/corda.git
synced 2025-03-14 00:06:45 +00:00
Rebased on master (tested manually against simm-valuation-demo)
This commit is contained in:
parent
5ea82039d7
commit
7d71233a35
@ -4,6 +4,7 @@ package net.corda.launcher
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
@ -14,7 +15,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
// TODO: --base-directory is specific of the Node app, it should be controllable by a config property
|
||||
val nodeBaseDir = Settings.WORKING_DIR
|
||||
val nodeBaseDir = Paths.get(Settings.WORKING_DIR)
|
||||
.resolve(getBaseDirectory(args) ?: ".")
|
||||
.toAbsolutePath()
|
||||
|
||||
@ -31,8 +32,8 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
// Propagate current working directory via system property, to patch it after javapackager
|
||||
System.setProperty("corda.launcher.cwd", nodeBaseDir.toString())
|
||||
System.setProperty("user.dir", nodeBaseDir.toString())
|
||||
System.setProperty("corda-launcher.cwd", Settings.WORKING_DIR)
|
||||
System.setProperty("user.dir", Settings.WORKING_DIR)
|
||||
|
||||
try {
|
||||
appMain.invoke(null, args.sliceArray(1..args.lastIndex))
|
||||
@ -63,7 +64,7 @@ private fun setupClassLoader(nodeBaseDir: Path): ClassLoader {
|
||||
appClassLoader.augmentClasspath(pluginURLs)
|
||||
|
||||
// For logging
|
||||
System.setProperty("corda.launcher.appclassloader.urls", appClassLoader.urLs.joinToString(":"))
|
||||
System.setProperty("corda-launcher.appclassloader.urls", appClassLoader.urLs.joinToString(":"))
|
||||
|
||||
return appClassLoader
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ object Settings {
|
||||
private val CORDA_RUNTIME_SETTINGS = LAUNCHER_PATH.resolve("runtime.properties")
|
||||
|
||||
// The application working directory
|
||||
val WORKING_DIR: Path = System.getenv("CORDA_LAUNCHER_CWD")?.let {Paths.get(it)} ?: LAUNCHER_PATH
|
||||
val WORKING_DIR: String = System.getenv("CORDA_LAUNCHER_CWD") ?: ".."
|
||||
|
||||
// Application classpath
|
||||
val CLASSPATH: List<URL>
|
||||
|
@ -68,12 +68,12 @@ class NodeArgsParser : AbstractArgsParser<CmdLineOptions>() {
|
||||
require(!optionSet.has(baseDirectoryArg) || !optionSet.has(configFileArg)) {
|
||||
"${baseDirectoryArg.options()[0]} and ${configFileArg.options()[0]} cannot be specified together"
|
||||
}
|
||||
// Note: this is a workaround for javapackager misbehaving with cwd.
|
||||
// The correct working directory is propagated from launcher via system property.
|
||||
// Workaround for javapackager polluting cwd: restore it from system property set by launcher.
|
||||
val baseDirectory = System.getProperty("corda.launcher.cwd")?.let { Paths.get(it) }
|
||||
?: optionSet.valueOf(baseDirectoryArg)
|
||||
.normalize()
|
||||
.toAbsolutePath()
|
||||
|
||||
val configFile = baseDirectory / optionSet.valueOf(configFileArg)
|
||||
val loggingLevel = optionSet.valueOf(loggerLevel)
|
||||
val logToConsole = optionSet.has(logToConsoleArg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user