57 lines
2.6 KiB
Python
57 lines
2.6 KiB
Python
import os
|
||
from celery import Celery
|
||
#from celery.schedules import crontab
|
||
from datetime import timedelta
|
||
|
||
# set the default Django settings module for the 'celery' program.
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mfssogr.settings')
|
||
|
||
app = Celery('mfssogr')
|
||
|
||
# Using a string here means the worker doesn't have to serialize
|
||
# the configuration object to child processes.
|
||
# - namespace='CELERY' means all celery-related configuration keys
|
||
# should have a `CELERY_` prefix.
|
||
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||
|
||
# Load task modules from all registered Django app configs.
|
||
app.autodiscover_tasks()
|
||
|
||
|
||
@app.task(bind=True, ignore_result=True)
|
||
def debug_task(self):
|
||
print(f'Request: {self.request!r}')
|
||
|
||
app.conf.enable_utc = False
|
||
app.conf.beat_schedule = {
|
||
'apps.schedulers.tasks.test_task': {# Получение данных по землятресениям
|
||
'task': 'apps.schedulers.tasks.test_task',
|
||
'schedule': timedelta(minutes=30), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
|
||
},
|
||
#'apps.schedulers.tasks.update_block': {# Получение данных по блокировкам
|
||
# 'task': 'apps.schedulers.tasks.update_block',
|
||
# 'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
|
||
#},
|
||
#'apps.schedulers.tasks.update_ops_skpv_date': { # Получение данных со водоснабжение
|
||
# 'task': 'apps.schedulers.tasks.update_ops_skpv_date',
|
||
# 'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
|
||
#},
|
||
#'apps.schedulers.tasks.update_ops_ppz_date': { # Получение данных противопожарная защита
|
||
# 'task': 'apps.schedulers.tasks.update_ops_ppz_date',
|
||
# 'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
|
||
#},
|
||
#'apps.schedulers.tasks.update_ops_scada_date': { # Получение данных Системы контроля работы оборудования
|
||
# 'task': 'apps.schedulers.tasks.update_ops_scada_date',
|
||
# 'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
|
||
#},
|
||
|
||
#'apps.schedulers.tasks.update_eps': {
|
||
# 'task': 'apps.schedulers.tasks.update_eps',
|
||
# 'schedule': timedelta(minutes=5), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
|
||
#},
|
||
|
||
|
||
|
||
|
||
}
|
||
|