mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
Easy all in one launch of UI + SSH tunnels.
This commit is contained in:
parent
766c0b23d2
commit
b7fb87ed83
@ -13,6 +13,7 @@ class Launcher {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val logger = LoggerFactory.getLogger(this::class.java)
|
val logger = LoggerFactory.getLogger(this::class.java)
|
||||||
|
logger.info("Launcher called with ${args.toList()}")
|
||||||
val jmeter = JMeter()
|
val jmeter = JMeter()
|
||||||
val capsuleDir = System.getProperty("capsule.dir")
|
val capsuleDir = System.getProperty("capsule.dir")
|
||||||
if (capsuleDir != null) {
|
if (capsuleDir != null) {
|
||||||
@ -44,8 +45,21 @@ class Launcher {
|
|||||||
}
|
}
|
||||||
jmeter.start(arrayOf("-s", "-p", (capsuleDirPath / "jmeter.properties").toString()) + extraArgs + args)
|
jmeter.start(arrayOf("-s", "-p", (capsuleDirPath / "jmeter.properties").toString()) + extraArgs + args)
|
||||||
} else {
|
} else {
|
||||||
jmeter.start(args)
|
jmeter.start(maybeOpenSshTunnels(args))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun maybeOpenSshTunnels(args: Array<String>): Array<String> {
|
||||||
|
var index = 0
|
||||||
|
for (arg in args) {
|
||||||
|
if (arg == "-Xssh") {
|
||||||
|
// start ssh
|
||||||
|
Ssh.main(args.copyOfRange(index + 1, args.size), false)
|
||||||
|
return if (index == 0) emptyArray() else args.copyOfRange(0, index)
|
||||||
|
}
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
return args
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import com.jcraft.jsch.JSch
|
|||||||
import com.jcraft.jsch.Session
|
import com.jcraft.jsch.Session
|
||||||
import net.corda.core.utilities.NetworkHostAndPort
|
import net.corda.core.utilities.NetworkHostAndPort
|
||||||
import net.corda.loadtest.setupJSchWithSshAgent
|
import net.corda.loadtest.setupJSchWithSshAgent
|
||||||
|
import net.corda.nodeapi.internal.addShutdownHook
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
@ -15,7 +16,8 @@ class Ssh {
|
|||||||
val log = LoggerFactory.getLogger(this::class.java)
|
val log = LoggerFactory.getLogger(this::class.java)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
@JvmOverloads
|
||||||
|
fun main(args: Array<String>, wait: Boolean = true) {
|
||||||
val userName = System.getProperty("user.name")
|
val userName = System.getProperty("user.name")
|
||||||
val jsch = setupJSchWithSshAgent()
|
val jsch = setupJSchWithSshAgent()
|
||||||
val sessions = mutableListOf<Session>()
|
val sessions = mutableListOf<Session>()
|
||||||
@ -58,8 +60,9 @@ class Ssh {
|
|||||||
// ssh ${remoteHostAndPort.host} -R 0.0.0.0:clientRmiLocalPort:localhost:clientRmiLocalPort -N
|
// ssh ${remoteHostAndPort.host} -R 0.0.0.0:clientRmiLocalPort:localhost:clientRmiLocalPort -N
|
||||||
createInboundTunnel(session, NetworkHostAndPort("0.0.0.0", clientRmiLocalPort), NetworkHostAndPort("localhost", clientRmiLocalPort))
|
createInboundTunnel(session, NetworkHostAndPort("0.0.0.0", clientRmiLocalPort), NetworkHostAndPort("localhost", clientRmiLocalPort))
|
||||||
}
|
}
|
||||||
val input = BufferedReader(InputStreamReader(System.`in`))
|
|
||||||
|
|
||||||
|
if (wait) {
|
||||||
|
val input = BufferedReader(InputStreamReader(System.`in`))
|
||||||
do {
|
do {
|
||||||
log.info("Type 'quit' to exit cleanly.")
|
log.info("Type 'quit' to exit cleanly.")
|
||||||
} while (input.readLine() != "quit")
|
} while (input.readLine() != "quit")
|
||||||
@ -67,6 +70,14 @@ class Ssh {
|
|||||||
log.info("Closing tunnels for ${it.host}")
|
log.info("Closing tunnels for ${it.host}")
|
||||||
it.disconnect()
|
it.disconnect()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
addShutdownHook {
|
||||||
|
sessions.forEach {
|
||||||
|
log.info("Closing tunnels for ${it.host}")
|
||||||
|
it.disconnect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadProps(filename: String): Properties {
|
private fun loadProps(filename: String): Properties {
|
||||||
|
Loading…
Reference in New Issue
Block a user