Skip to content

Commit

Permalink
Merge pull request #196 from CoolPeace-yanolza/develop
Browse files Browse the repository at this point in the history
1월 25일 18시 배포
  • Loading branch information
tkddn204 authored Jan 25, 2024
2 parents 941abe4 + 77f93ea commit fd8a449
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.coolpeace.global.config;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Component
public class ActuatorHealthIndicator implements HealthIndicator {

private static final String LOCAL_DATE_TIME_KOR_FORMAT = "yyyy년 MM월 dd일 HH시 mm분 ss초";

private final LocalDateTime serverStartLocalDateTime = LocalDateTime.now();

@Override
public Health getHealth(boolean includeDetails) {
long millis = serverStartLocalDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
long uptime = (System.currentTimeMillis() - millis) / 1000;
return Health.up()
.withDetail("startDate", serverStartLocalDateTime.format(DateTimeFormatter.ofPattern(LOCAL_DATE_TIME_KOR_FORMAT)))
.withDetail("uptime", uptime)
.build();
}

@Override
public Health health() {
return getHealth(true);
}
}

0 comments on commit fd8a449

Please sign in to comment.