cschneider / Karaf-Tutorial

http://cschneider.github.io/Karaf-Tutorial/
Apache License 2.0
271 stars 305 forks source link

how to know when karaf is started completely? #52

Closed minikiller closed 5 years ago

minikiller commented 5 years ago

hi: I face a situation,when i boot up karaf i want to show some info to user. Such as db connection is good,redis is prepared. I want to know under karaf, how can i have chane to do this? thanks!

cschneider commented 5 years ago

You can put code in one of your bundles that checks the db connection and outputs the readiness using System.out. The user will then see this on the karaf console.

It is not recommended though to write to the console outside of commands as the printout might interfere with what the user is writing. So the more common way is to simply write this information to the log.

Btw. why do you want to display it? Is the user expected to do something when the db is ready?

minikiller commented 5 years ago

Thank very much for your reply. I found the code from https://github.com/apache/karaf/blob/cffa8250da16c9be9023ea5abeaddfc3bae4e746/main/src/main/java/org/apache/karaf/main/StartupListener.java. It fullly satisfy my demand. I also show message on the console, but my bundle number is larger ,so the message will be disappeared after other bundle started. thank for you again.