시간값 수정 .
parent
2a25640535
commit
faeb05537c
|
|
@ -1,6 +1,11 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
from pathlib import Path
|
||||
|
||||
TIMEZONE = ZoneInfo(os.getenv("TIMEZONE", "Asia/Seoul"))
|
||||
|
||||
PROJECT_DIR = Path(__file__).resolve().parent
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,11 @@ scheduled_at이 현재 시간 이전이고 status가 pending인 업로드 작업
|
|||
import asyncio
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import httpx
|
||||
from sqlalchemy import text
|
||||
|
||||
from config import settings
|
||||
from config import settings, TIMEZONE
|
||||
from db import SessionLocal
|
||||
from jobs.base import BaseJob
|
||||
|
||||
|
|
@ -47,7 +46,7 @@ class SnsUploadJob(BaseJob):
|
|||
|
||||
async def _fetch_pending_uploads(self) -> list[int]:
|
||||
# DB의 다른 datetime 컬럼과 동일하게 Seoul time naive로 비교
|
||||
now = datetime.now(ZoneInfo("Asia/Seoul")).replace(tzinfo=None).strftime("%Y-%m-%d %H:%M:%S")
|
||||
now = datetime.now(TIMEZONE).replace(tzinfo=None).strftime("%Y-%m-%d %H:%M:%S")
|
||||
query = text("""
|
||||
SELECT id FROM social_upload
|
||||
WHERE status = 'pending'
|
||||
|
|
|
|||
7
main.py
7
main.py
|
|
@ -6,15 +6,18 @@ APScheduler를 사용하여 jobs/ 에 등록된 잡들을 주기적으로 실행
|
|||
|
||||
import asyncio
|
||||
import logging
|
||||
import time
|
||||
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
|
||||
from config import settings
|
||||
from config import settings, TIMEZONE
|
||||
from jobs import JOBS
|
||||
|
||||
# 로그 타임스탬프를 KST로 출력
|
||||
logging.Formatter.converter = lambda *args: __import__("datetime").datetime.now(TIMEZONE).timetuple()
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="[%(asctime)s] [%(levelname)s] %(name)s - %(message)s",
|
||||
format="[%(asctime)s KST] [%(levelname)s] %(name)s - %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue