-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
261 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
release: python manage.py migrate | ||
web: gunicorn config.wsgi --log-file - | ||
worker: celery -A config worker -l info --concurrency=4 | ||
beat: celery -A config beat -l info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .celery import app as celery_app | ||
|
||
__all__ = ("celery_app",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
|
||
from celery import Celery | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") | ||
|
||
app = Celery("config") | ||
|
||
app.config_from_object("django.conf:settings", namespace="CELERY") | ||
|
||
# Auto-discover tasks in all installed apps | ||
# This will look for a 'tasks.py' file in each app directory | ||
app.autodiscover_tasks() | ||
|
||
|
||
@app.task(bind=True) | ||
def debug_task(self): | ||
"""A simple task for testing Celery setup""" | ||
print(f"Request: {self.request!r}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from celery import shared_task | ||
from celery.utils.log import get_task_logger | ||
from django.core.management import call_command | ||
|
||
from contributors.management.commands.fetchdata import ORGANIZATIONS | ||
|
||
logger = get_task_logger(__name__) | ||
|
||
|
||
@shared_task(bind=True, max_retries=3) | ||
def sync_github_data(self, owners=None, repos=None): | ||
try: | ||
orgs = [org.name for org in ORGANIZATIONS] | ||
logger.info(orgs) | ||
call_command("fetchdata", orgs or ["hexlet"], repo=repos or []) | ||
|
||
except Exception as exc: | ||
logger.error(f"Failed to sync GitHub data: {exc}") | ||
self.retry(exc=exc, countdown=60 * (2**self.request.retries)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.