Fynjy
8 months ago
1 changed files with 15 additions and 21 deletions
@ -1,21 +1,15 @@ |
|||||||
from __future__ import absolute_import, unicode_literals |
from __future__ import absolute_import, unicode_literals |
||||||
import os |
import os |
||||||
from celery import Celery |
from celery import Celery |
||||||
from celery.schedules import crontab |
|
||||||
from crossposting_backend.tasks import delayed_post |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crossposting_backend.settings') |
||||||
|
|
||||||
|
CELERY_TIMEZONE = 'Europe/Moscow' |
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crossposting_backend') |
|
||||||
|
app = Celery('cms') |
||||||
app = Celery('crossposting_backend') |
app.config_from_object('django.conf:settings', namespace='CELERY') |
||||||
app.config_from_object('django.conf:settings', namespace='CELERY') |
app.autodiscover_tasks() |
||||||
app.autodiscover_tasks() |
|
||||||
|
@app.task(bind=True) |
||||||
CELERY_BEAT_SCHEDULE = { |
def debug_task(self): |
||||||
# Задача, которая будет выполнять отложенные публикации |
print(f'Request {self.request!r}') |
||||||
'post-articles': { |
|
||||||
'task': 'crossposting_backend.tasks.delayed_post', |
|
||||||
'schedule': crontab(minute=0, hour='*'), # Запускать каждую минуту |
|
||||||
'args': () # Аргументы задачи, в данном случае их нет |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue