File tree Expand file tree Collapse file tree
backend/api/src/main/kotlin/org/rm3l/devfeed/actuator Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525package org.rm3l.devfeed.actuator
2626
2727import org.rm3l.devfeed.persistence.DevFeedDao
28+ import org.slf4j.LoggerFactory
2829import org.springframework.boot.actuate.health.Health
2930import org.springframework.boot.actuate.health.HealthIndicator
3031import org.springframework.stereotype.Service
3132
3233@Service
3334class DevFeedHealthChecker (private val dao : DevFeedDao ) : HealthIndicator {
3435
36+ companion object {
37+ @JvmStatic private val logger = LoggerFactory .getLogger(DevFeedHealthChecker ::class .java)
38+ }
39+
3540 override fun health (): Health =
36- if (dao.getArticles(limit = 1 ).isNotEmpty()) {
41+ try {
42+ dao.checkHealth()
3743 Health .up().build()
38- } else {
44+ } catch (e: Exception ) {
45+ logger.warn(" Application down due to the following health check error: ${e.message} " )
46+ if (logger.isDebugEnabled) {
47+ logger.debug(e.message, e)
48+ }
3949 Health .down().build()
4050 }
4151}
You can’t perform that action at this time.
0 commit comments