Skip to content

Commit

Permalink
Fix: update timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
junho100 committed Nov 25, 2024
1 parent a085bc7 commit ee17e9a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions internal/infrastructure/cron/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ type CronJob struct {
}

func NewCronJob(notificationService service.NotificationService, telegramClient telegram.TelegramClient, notificationStatus redis.NotificationStatus, crawler crawler.Crawler) *CronJob {
// CRON_TZ=Asia/Seoul 설정으로 한국 시간 기준으로 동작하도록 설정
loc, err := time.LoadLocation("Asia/Seoul")
if err != nil {
log.Printf("Failed to load location: %v", err)
return nil
}
// UTC+9 시간으로 고정 설정
loc := time.FixedZone("KST", 9*60*60) // UTC+9 시간

c := cron.New(cron.WithLocation(loc))
return &CronJob{
Expand All @@ -44,8 +40,8 @@ func NewCronJob(notificationService service.NotificationService, telegramClient
}

func (c *CronJob) Start() {
// 매일 오후 12시에 실행 (한국 시간)
c.cron.AddFunc("0 0 15 * * *", func() {
// 매일 오전 12시 30분에 실행 (한국 시간)
c.cron.AddFunc("0 30 0 * * *", func() {
// 1. 오늘 올라온 모든 공지사항 크롤링 및 DB 저장
deptNotices, err := c.crawler.FetchDepartmentNotices()
if err != nil {
Expand Down

0 comments on commit ee17e9a

Please sign in to comment.