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() {
|
||||
if (configuration.shouldInitCrashShell()) {
|
||||
val isShellStarted = InteractiveShell.startShellIfInstalled(configuration, cordappLoader)
|
||||
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")
|
||||
|
||||
// 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)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
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 ->
|
||||
|
@ -17,28 +17,36 @@ object InteractiveShell {
|
||||
private const val RUN_LOCAL_SHELL_METHOD = "runLocalShell"
|
||||
private const val SET_USER_INFO_METHOD = "setUserInfo"
|
||||
|
||||
fun startShellIfInstalled(configuration: NodeConfiguration, cordappLoader: CordappLoader) {
|
||||
if (isShellInstalled()) {
|
||||
fun startShellIfInstalled(configuration: NodeConfiguration, cordappLoader: CordappLoader): Boolean {
|
||||
return if (isShellInstalled()) {
|
||||
try {
|
||||
val shellConfiguration = configuration.toShellConfigMap()
|
||||
setUnsafeUsers(configuration)
|
||||
startShell(shellConfiguration, cordappLoader)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
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.
|
||||
*/
|
||||
fun runLocalShellIfInstalled(onExit: () -> Unit = {}) {
|
||||
if (isShellInstalled()) {
|
||||
fun runLocalShellIfInstalled(onExit: () -> Unit = {}): Boolean {
|
||||
return if (isShellInstalled()) {
|
||||
try {
|
||||
runLocalShell(onExit)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
log.error("Shell failed to start", e)
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user