Skip to content

Commit

Permalink
feat: implement runserver_with_q command to start Django Q alongside …
Browse files Browse the repository at this point in the history
…the server
  • Loading branch information
kshitijrajsharma committed Jan 9, 2025
1 parent 19ea774 commit 33fafa0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/Dockerfile.API
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ EXPOSE 8000

#ENTRYPOINT ["/app/api-entrypoint-lock.sh"]

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
CMD ["python", "manage.py", "runserver_with_q", "0.0.0.0:8000"]
2 changes: 1 addition & 1 deletion backend/aiproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"queue_limit": 50,
"timeout": 60 * 5, # number of seconds
"label": "Django Q",
"BUCKET_NAMEorm": "default",
"orm": "default",
}


Expand Down
15 changes: 15 additions & 0 deletions backend/core/management/commands/runserver_with_q.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import multiprocessing
import os

from django.core.management import call_command
from django.core.management.commands.runserver import Command as RunserverCommand


class Command(RunserverCommand):
def handle(self, *args, **options):
multiprocessing.Process(target=self.start_django_q).start()

super().handle(*args, **options)

def start_django_q(self):
call_command("qcluster")

0 comments on commit 33fafa0

Please sign in to comment.