mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
ENT-6676 Don't log SSH port if shell not installed (#7059)
This commit is contained in:
parent
0b8c46e1b2
commit
7afb585ae2
@ -687,10 +687,14 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
|||||||
|
|
||||||
open fun startShell() {
|
open fun startShell() {
|
||||||
if (configuration.shouldInitCrashShell()) {
|
if (configuration.shouldInitCrashShell()) {
|
||||||
|
val isShellStarted = InteractiveShell.startShellIfInstalled(configuration, cordappLoader)
|
||||||
configuration.sshd?.port?.let {
|
configuration.sshd?.port?.let {
|
||||||
log.info("Binding Shell SSHD server on port $it.")
|
if (isShellStarted) {
|
||||||
|
log.info("Binding Shell SSHD server on port $it.")
|
||||||
|
} else {
|
||||||
|
log.info("SSH port defined but corda-shell is not installed in node's drivers directory")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InteractiveShell.startShellIfInstalled(configuration, cordappLoader)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,11 +263,19 @@ open class NodeStartup : NodeStartupLogging {
|
|||||||
Node.printBasicNodeInfo("Node for \"$name\" started up and registered in $elapsed sec")
|
Node.printBasicNodeInfo("Node for \"$name\" started up and registered in $elapsed sec")
|
||||||
|
|
||||||
// Don't start the shell if there's no console attached.
|
// Don't start the shell if there's no console attached.
|
||||||
if (node.configuration.shouldStartLocalShell()) {
|
val isShellStarted = if (node.configuration.shouldStartLocalShell()) {
|
||||||
InteractiveShell.runLocalShellIfInstalled(node::stop)
|
InteractiveShell.runLocalShellIfInstalled(node::stop)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
if (node.configuration.shouldStartSSHDaemon()) {
|
if (node.configuration.shouldStartSSHDaemon()) {
|
||||||
Node.printBasicNodeInfo("SSH server listening on port", node.configuration.sshd!!.port.toString())
|
if (isShellStarted) {
|
||||||
|
Node.printBasicNodeInfo("SSH server listening on port", node.configuration.sshd!!.port.toString())
|
||||||
|
} else {
|
||||||
|
Node.printBasicNodeInfo(
|
||||||
|
"SSH server not started. SSH port is defined but the corda-shell is not installed in node's drivers directory"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ th ->
|
{ th ->
|
||||||
|
@ -17,28 +17,36 @@ object InteractiveShell {
|
|||||||
private const val RUN_LOCAL_SHELL_METHOD = "runLocalShell"
|
private const val RUN_LOCAL_SHELL_METHOD = "runLocalShell"
|
||||||
private const val SET_USER_INFO_METHOD = "setUserInfo"
|
private const val SET_USER_INFO_METHOD = "setUserInfo"
|
||||||
|
|
||||||
fun startShellIfInstalled(configuration: NodeConfiguration, cordappLoader: CordappLoader) {
|
fun startShellIfInstalled(configuration: NodeConfiguration, cordappLoader: CordappLoader): Boolean {
|
||||||
if (isShellInstalled()) {
|
return if (isShellInstalled()) {
|
||||||
try {
|
try {
|
||||||
val shellConfiguration = configuration.toShellConfigMap()
|
val shellConfiguration = configuration.toShellConfigMap()
|
||||||
setUnsafeUsers(configuration)
|
setUnsafeUsers(configuration)
|
||||||
startShell(shellConfiguration, cordappLoader)
|
startShell(shellConfiguration, cordappLoader)
|
||||||
|
true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.error("Shell failed to start", e)
|
log.error("Shell failed to start", e)
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only call this after [startShellIfInstalled] has been called or the required classes will not be loaded into the current classloader.
|
* Only call this after [startShellIfInstalled] has been called or the required classes will not be loaded into the current classloader.
|
||||||
*/
|
*/
|
||||||
fun runLocalShellIfInstalled(onExit: () -> Unit = {}) {
|
fun runLocalShellIfInstalled(onExit: () -> Unit = {}): Boolean {
|
||||||
if (isShellInstalled()) {
|
return if (isShellInstalled()) {
|
||||||
try {
|
try {
|
||||||
runLocalShell(onExit)
|
runLocalShell(onExit)
|
||||||
|
true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.error("Shell failed to start", e)
|
log.error("Shell failed to start", e)
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user