title: Spring Boot - Wait for web server to start
body: <p>In my Spring Boot application I need to wait until the (default Tomcat) web server is fully initialized and ready to take traffic before I send messages to other applications telling them to send HTTP requests to me (specifically a monitoring system that hits my <code>/health</code>).</p>
  
  <p>I've tried putting the logic that sends messages to other applications in a <code>ApplicationListener&lt;ContextRefreshedEvent&gt;</code> but it's still too early. The other applications try to make requests to me and fail.  Right now I've put a delay in the <code>onApplicationEvent</code> and that works but it's hacky and racy.</p>
  
  <p>I've also tried adding a <code>ServletContextInitializer</code> but that fired even earlier.</p>
  
  <p>I'm assuming that I'll need to use a Tomcat API but I wanted to see if there was something in the Boot API for this.</p>