Merge remote-tracking branch 'origin/main' into develop

This commit is contained in:
htlee 2026-03-18 08:58:09 +09:00
커밋 7fabe16f4f
3개의 변경된 파일23개의 추가작업 그리고 28개의 파일을 삭제

파일 보기

@ -85,43 +85,40 @@ jobs:
- name: Restart backend via SSH
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_HOST: 192.168.1.20
run: |
mkdir -p ~/.ssh
echo "$DEPLOY_KEY" > ~/.ssh/id_deploy
printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/id_deploy
chmod 600 ~/.ssh/id_deploy
# Docker 컨테이너 → 호스트: bridge gateway(172.17.0.1) 경유
DOCKER_HOST_IP=172.17.0.1
ssh-keyscan $DOCKER_HOST_IP >> ~/.ssh/known_hosts 2>/dev/null || true
ssh-keyscan -T 5 $DEPLOY_HOST >> ~/.ssh/known_hosts 2>/dev/null || true
SSH_CMD="ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no root@$DOCKER_HOST_IP"
SSH_CMD="ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no -o ConnectTimeout=10 root@$DEPLOY_HOST"
$SSH_CMD bash -s << 'RESTART'
set -e
DEPLOY_DIR=/devdata/services/kcg/backend
SYSTEMD_DIR=/etc/systemd/system
# systemd 서비스 파일 갱신
CHANGED=0
if [ -f "$DEPLOY_DIR/kcg-backend.service" ] && ! diff -q "$DEPLOY_DIR/kcg-backend.service" "$SYSTEMD_DIR/kcg-backend.service" >/dev/null 2>&1; then
cp "$DEPLOY_DIR/kcg-backend.service" "$SYSTEMD_DIR/kcg-backend.service"
CHANGED=1
systemctl daemon-reload
fi
[ "$CHANGED" = "1" ] && systemctl daemon-reload
# 백엔드 재시작
echo "--- Restarting kcg-backend ---"
systemctl restart kcg-backend
# 기동 확인 (최대 30초)
for i in $(seq 1 30); do
if curl -sf http://localhost:8080/api/aircraft > /dev/null 2>&1; then
echo "Backend started successfully (${i}s)"
# 기동 확인 (최대 60초)
for i in $(seq 1 60); do
HTTP=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/api/aircraft 2>/dev/null || echo "000")
if [ "$HTTP" = "200" ] || [ "$HTTP" = "401" ] || [ "$HTTP" = "403" ]; then
echo "Backend started successfully (${i}s, HTTP $HTTP)"
exit 0
fi
sleep 1
done
echo "WARNING: Startup timeout. Recent logs:"
journalctl -u kcg-backend --no-pager -n 20
echo "WARNING: Startup timeout"
journalctl -u kcg-backend --no-pager -n 10
exit 1
RESTART

파일 보기

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

파일 보기

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