Skip to content

Commit

Permalink
schedule searchvector command
Browse files Browse the repository at this point in the history
  • Loading branch information
oleggator committed Oct 1, 2019
1 parent c5cd4a0 commit eb7d01c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions jarbas/celery.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
import os
from celery import Celery
from celery.schedules import crontab


os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jarbas.settings')

app = Celery('jarbas')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()


@app.on_after_configure.connect
def setup_periodic_tasks(sender, **kwargs):
from django.core import management

@app.task(ignore_result=True)
def searchvector():
management.call_command('searchvector')

sender.add_periodic_task(
crontab(minute='0', hour='2', day_of_month='*/2'),
searchvector.s(),
)

0 comments on commit eb7d01c

Please sign in to comment.