Skip to content

Commit

Permalink
fix: celery worker for issue activities (#744)
Browse files Browse the repository at this point in the history
* dev: update celery configuration to root folder

* dev: update import for celery

* fix: worker to deserialize data
  • Loading branch information
pablohashescobar authored Apr 8, 2023
1 parent c21fb6e commit d88a95b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
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']

0 comments on commit d88a95b

Please sign in to comment.