Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: celery worker for issue activities #744

Merged
merged 3 commits into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apiserver/Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker plane.asgi:application --bind 0.0.0.0:$PORT --config gunicorn.config.py --max-requests 10000 --max-requests-jitter 1000 --access-logfile -
worker: celery -A plane.settings.celery worker -l info
worker: celery -A plane worker -l info
3 changes: 3 additions & 0 deletions apiserver/plane/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .celery import app as celery_app

__all__ = ('celery_app',)
14 changes: 14 additions & 0 deletions apiserver/plane/bgtasks/issue_activites_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def track_priority(
comment=f"{actor.email} updated the priority to {requested_data.get('priority')}",
)
)
print(issue_activities)


# Track chnages in state of the issue
Expand Down Expand Up @@ -651,6 +652,18 @@ def update_issue_activity(
"cycles_list": track_cycles,
"modules_list": track_modules,
}

requested_data = (
json.loads(requested_data)
if requested_data is not None
else None
)
current_instance = (
json.loads(current_instance)
if current_instance is not None
else None
)

for key in requested_data:
func = ISSUE_ACTIVITY_MAPPER.get(key, None)
if func is not None:
Expand Down Expand Up @@ -786,5 +799,6 @@ def issue_activity(
)
return
except Exception as e:
print(e)
capture_exception(e)
return
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
from celery import Celery
from django.conf import settings
from plane.settings.redis import redis_instance

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plane.settings.production")

ri = redis_instance()

app = Celery("plane")

# Using a string here means the worker will not have to
Expand Down
3 changes: 0 additions & 3 deletions apiserver/plane/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .celery import app as celery_app

__all__ = ('celery_app',)
4 changes: 4 additions & 0 deletions apiserver/plane/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,7 @@
"SLIDING_TOKEN_LIFETIME": timedelta(minutes=5),
"SLIDING_TOKEN_REFRESH_LIFETIME": timedelta(days=1),
}

CELERY_TIMEZONE = TIME_ZONE
CELERY_TASK_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['application/json']