Add logging to node startup when it attempt to connect to the map server (#167)

* Add logging to avoid node startup "hang" when it attempt to connects to the network map, also can use as a hint telling user Network map might be down or unreachable.
This commit is contained in:
Patrick Kuo 2017-01-20 11:34:32 +00:00 committed by GitHub
parent 2ec31781c1
commit aeb5a59605

View File

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory
import java.lang.management.ManagementFactory
import java.net.InetAddress
import java.nio.file.Paths
import kotlin.concurrent.thread
import kotlin.system.exitProcess
private var renderBasicInfoToConsole = true
@ -85,6 +86,14 @@ fun main(args: Array<String>) {
node.start()
printPluginsAndServices(node)
thread {
Thread.sleep(30.seconds.toMillis())
while (!node.networkMapRegistrationFuture.isDone) {
printBasicNodeInfo("Waiting for response from network map ...")
Thread.sleep(30.seconds.toMillis())
}
}
node.networkMapRegistrationFuture.success {
val elapsed = (System.currentTimeMillis() - startTime) / 10 / 100.0
printBasicNodeInfo("Node started up and registered in $elapsed sec")