File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
pythonkr_backend/curation Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change
1
+ import logfire
2
+ from celery import Celery
3
+ from celery .signals import worker_init , beat_init
4
+
1
5
from celery import shared_task
2
6
import feedparser
3
7
import requests
4
8
from datetime import datetime , timezone
5
9
from django .utils import timezone as django_timezone
6
10
from .models import RSSFeed , RSSItem
7
- import logfire
8
11
import logging
9
12
10
13
logger = logging .getLogger (__name__ )
11
14
12
15
13
- @shared_task
16
+ @worker_init .connect ()
17
+ def init_worker (* args , ** kwargs ):
18
+ logfire .configure (service_name = "worker" )
19
+ logfire .instrument_celery ()
20
+
21
+ @beat_init .connect ()
22
+ def init_beat (* args , ** kwargs ):
23
+ logfire .configure (service_name = "beat" )
24
+ logfire .instrument_celery ()
25
+
14
26
def crawl_all_rss_feeds ():
15
27
"""모든 활성화된 RSS 피드를 크롤링합니다."""
16
28
active_feeds = RSSFeed .objects .filter (is_active = True )
@@ -135,9 +147,6 @@ def crawl_single_rss_feed(feed_id):
135
147
@shared_task
136
148
def crawl_rss ():
137
149
"""10분마다 실행되는 RSS 크롤링 태스크"""
150
+ logfire .info ("start to crawl rss" )
151
+ logger .info ("start to crawl rss" )
138
152
return crawl_all_rss_feeds ()
139
-
140
-
141
- @shared_task
142
- def crawl_url ():
143
- pass
You can’t perform that action at this time.
0 commit comments