docs: 점심 월드컵 스케줄러 리팩토링 내용 반영
- 스케줄러 모듈 분리 방식 추가 (app/scheduler/jobs/lunch_worldcup.py) - 환경변수 제어 방식 명시 (LUNCH_WORLDCUP_ENABLED, LUNCH_WORLDCUP_SCHEDULE) - 교훈 업데이트: 하드코딩 금지, register 패턴 통일 - 트러블슈팅 추가: 하드코딩 스케줄 제거 과정 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d9a01d33ae
commit
269c96067d
@ -48,15 +48,21 @@ async def send_lunch_worldcup_notification(channel_id: str = None):
|
||||
# 랜덤 메시지 + 버튼 링크
|
||||
```
|
||||
|
||||
#### 스케줄러 모듈 생성 (2025-09-27 리팩토링)
|
||||
```
|
||||
app/scheduler/jobs/lunch_worldcup.py
|
||||
```
|
||||
|
||||
```python
|
||||
# register(scheduler) 패턴 사용
|
||||
# 환경변수: LUNCH_WORLDCUP_ENABLED, LUNCH_WORLDCUP_SCHEDULE
|
||||
# 참조: naverworks_briefing.py
|
||||
```
|
||||
|
||||
#### main.py 스케줄 등록
|
||||
```python
|
||||
from app.notifications import send_lunch_worldcup_notification
|
||||
scheduler.add_job(
|
||||
send_lunch_worldcup_notification,
|
||||
CronTrigger.from_crontab("0 12 * * 1-5", timezone='Asia/Seoul'),
|
||||
id='lunch_worldcup',
|
||||
replace_existing=True
|
||||
)
|
||||
from app.scheduler.jobs import lunch_worldcup
|
||||
lunch_worldcup.register(scheduler)
|
||||
```
|
||||
|
||||
## 배포 정보
|
||||
@ -66,10 +72,11 @@ scheduler.add_job(
|
||||
|
||||
## 교훈
|
||||
1. **main.py 역할 명확화**: 스케줄 등록만, 로직은 별도 모듈
|
||||
2. **파일 구조 설계**: 알림은 notifications/, 스킬은 skills/
|
||||
2. **파일 구조 설계**: 알림은 notifications/, 스킬은 skills/, 스케줄은 scheduler/jobs/
|
||||
3. **라우팅 경로 확인**: 404 에러시 App.tsx Route 확인
|
||||
4. **이미지 파일명**: 한글 파일명도 웹에서 동작하지만 영문 권장
|
||||
5. **환경변수 vs 하드코딩**: 크론 시간은 요구사항 확인 후 설정
|
||||
5. **환경변수 vs 하드코딩**: 절대 하드코딩 금지, 환경변수로 on/off 및 스케줄 제어 필수
|
||||
6. **스케줄러 패턴 통일**: register(scheduler) 함수로 모듈화, 에러 격리, 로깅 표준화
|
||||
|
||||
## 파일 변경 목록
|
||||
- frontend-customer:
|
||||
@ -80,9 +87,11 @@ scheduler.add_job(
|
||||
- rb8001:
|
||||
- app/notifications/lunch.py (생성)
|
||||
- app/notifications/__init__.py (생성)
|
||||
- main.py (스케줄 등록)
|
||||
- app/scheduler/jobs/lunch_worldcup.py (생성, 2025-09-27)
|
||||
- main.py (스케줄 등록 → register 호출로 변경, 2025-09-27)
|
||||
|
||||
## 트러블슈팅
|
||||
- 이미지 다운로드: Unsplash API 실패 → 나무위키 성공
|
||||
- 라우팅 404: /lunch → /lunch-worldcup 경로 수정
|
||||
- main.py 복잡도: 로직 분리하여 notifications 모듈 생성
|
||||
- main.py 복잡도: 로직 분리하여 notifications 모듈 생성
|
||||
- 하드코딩 스케줄 (2025-09-27): main.py에 평일 12시 고정 → scheduler/jobs 모듈로 분리, 환경변수 제어
|
||||
Loading…
x
Reference in New Issue
Block a user