title: liveness probe for microservice without http
body: <p>I have a microservice that is not a webservice.  </p>
  
  <p>It is a Spring Boot (1.5) CommandLineRunner app that does not have a need to expose an API or do anything with http.</p>
  
  <p>However, I need to give it a liveness probe for Kubernetes.</p>
  
  <p>Can this be accomplished without refactoring it into a webservice app?</p>
  
  <p>I have this configuration added to enable Spring's info endpoint</p>
  
  <pre><code>management:
    endpoint:
      health:
        enabled: true
      info:
        enabled: true
  
  # https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-endpoints
  info:
    app:
      name: foo-parser
      description: parses binary files from S3 and updates the database
  </code></pre>
  
  <p>I implemented this health check class</p>
  
  <pre><code>import org.springframework.boot.actuate.health.AbstractHealthIndicator;
  import org.springframework.boot.actuate.health.Health.Builder;
  
  @Component
  public class HealthCheck extends AbstractHealthIndicator {
  
    Logger log = LoggerFactory.getLogger("jsonLogger");
  
    private final MySQLAccessor mySQLAccessor;
    private static final String FOO_TABLE = "foo";
  
    @Autowired
    public HealthCheck(final MySQLAccessor mySQLAccessor) {
      this.mySQLAccessor = mySQLAccessor;
    }
  
    @Override
    protected void doHealthCheck(Builder builder) throws Exception {
      boolean result = mySQLAccessor.healthCheck(FOO_TABLE);
      if (result) {
        log.info("HELLO! the health check is good!");
        builder.up().withDetail("test", "good");
      }
      else {
        log.info("HELLO! OH NOES the health check is ungood!");
        builder.down().withDetail("test", "bad");
      }
    }
  }
  
  
  </code></pre>
  
  <p>Can this idea work?  Or do I have to refactor it to serve web requests?</p>
  
  <p>Thank you for any clues</p>