2017-09-27 11:04:18 -06:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from celery import Celery
|
|
|
|
|
|
|
|
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'network.settings')
|
|
|
|
|
|
|
|
from django.conf import settings # noqa
|
|
|
|
|
|
|
|
RUN_DAILY = 60 * 60 * 24
|
2018-08-24 15:35:19 -06:00
|
|
|
RUN_EVERY_TWO_HOURS = 2 * 60 * 60
|
2017-09-27 11:04:18 -06:00
|
|
|
RUN_HOURLY = 60 * 60
|
|
|
|
|
|
|
|
app = Celery('network')
|
|
|
|
|
|
|
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
|
|
|
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
|
|
|
|
|
|
|
|
|
|
|
@app.on_after_finalize.connect
|
|
|
|
def setup_periodic_tasks(sender, **kwargs):
|
2018-01-09 09:15:36 -07:00
|
|
|
from network.base.tasks import (update_all_tle, fetch_data, clean_observations,
|
2018-03-07 16:01:38 -07:00
|
|
|
station_status_update, stations_cache_rates)
|
2017-09-27 11:04:18 -06:00
|
|
|
|
2018-08-24 15:35:19 -06:00
|
|
|
sender.add_periodic_task(RUN_EVERY_TWO_HOURS, update_all_tle.s(),
|
2017-09-27 11:04:18 -06:00
|
|
|
name='update-all-tle')
|
|
|
|
|
|
|
|
sender.add_periodic_task(RUN_HOURLY, fetch_data.s(),
|
|
|
|
name='fetch-data')
|
|
|
|
|
2018-01-09 09:15:36 -07:00
|
|
|
sender.add_periodic_task(RUN_HOURLY, station_status_update.s(),
|
|
|
|
name='station-status-update')
|
|
|
|
|
2018-03-08 02:31:27 -07:00
|
|
|
sender.add_periodic_task(RUN_HOURLY, clean_observations.s(),
|
2017-09-27 11:05:12 -06:00
|
|
|
name='clean-observations')
|
2017-09-27 11:04:18 -06:00
|
|
|
|
2018-03-07 16:01:38 -07:00
|
|
|
sender.add_periodic_task(RUN_HOURLY, stations_cache_rates.s(),
|
|
|
|
name='stations-cache-rates')
|