fix(deploy): health check + PressureCollector 중복 방지 (#44)
Some checks failed
Deploy KCG / deploy (push) Failing after 1m12s

Co-authored-by: htlee <htlee@gcsc.co.kr>
Co-committed-by: htlee <htlee@gcsc.co.kr>
This commit is contained in:
htlee 2026-03-18 08:25:52 +09:00 committed by claude-bot
부모 c63af7abe0
커밋 1549adafc7
3개의 변경된 파일16개의 추가작업 그리고 17개의 파일을 삭제

파일 보기

@ -112,10 +112,11 @@ jobs:
echo "--- Restarting kcg-backend ---" echo "--- Restarting kcg-backend ---"
systemctl restart kcg-backend systemctl restart kcg-backend
# 기동 확인 (최대 30초) # 기동 확인 (최대 60초, 401=인증필요=정상 기동)
for i in $(seq 1 30); do for i in $(seq 1 60); do
if curl -sf http://localhost:8080/api/aircraft > /dev/null 2>&1; then HTTP=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/api/aircraft 2>/dev/null)
echo "Backend started successfully (${i}s)" if [ "$HTTP" = "200" ] || [ "$HTTP" = "401" ] || [ "$HTTP" = "403" ]; then
echo "Backend started successfully (${i}s, HTTP $HTTP)"
exit 0 exit 0
fi fi
sleep 1 sleep 1

파일 보기

@ -91,19 +91,16 @@ public class PressureCollector {
try { try {
// Open-Meteo 시간 형식: "2026-03-18T07:00" (Z 없음) Z 추가 // Open-Meteo 시간 형식: "2026-03-18T07:00" (Z 없음) Z 추가
Instant readingTime = OffsetDateTime.parse(timeStr + "Z").toInstant(); Instant readingTime = OffsetDateTime.parse(timeStr + "Z").toInstant();
try { if (repository.existsByStationAndReadingTime(station, readingTime)) continue;
repository.save(PressureReading.builder() repository.save(PressureReading.builder()
.station(station) .station(station)
.lat(lat) .lat(lat)
.lng(lng) .lng(lng)
.pressureHpa(pressure) .pressureHpa(pressure)
.readingTime(readingTime) .readingTime(readingTime)
.collectedAt(now) .collectedAt(now)
.build()); .build());
saved++; saved++;
} catch (Exception ignored) {
// unique constraint violation = 이미 존재, 무시
}
} catch (DateTimeParseException e) { } catch (DateTimeParseException e) {
log.debug("기압 시간 파싱 실패: {}", timeStr); log.debug("기압 시간 파싱 실패: {}", timeStr);
} }

파일 보기

@ -6,6 +6,7 @@ import java.time.Instant;
import java.util.List; import java.util.List;
public interface PressureReadingRepository extends JpaRepository<PressureReading, Long> { public interface PressureReadingRepository extends JpaRepository<PressureReading, Long> {
boolean existsByStationAndReadingTime(String station, Instant readingTime);
List<PressureReading> findByStationAndReadingTimeAfterOrderByReadingTimeAsc(String station, Instant since); List<PressureReading> findByStationAndReadingTimeAfterOrderByReadingTimeAsc(String station, Instant since);
List<PressureReading> findByReadingTimeAfterOrderByReadingTimeAsc(Instant since); List<PressureReading> findByReadingTimeAfterOrderByReadingTimeAsc(Instant since);
} }