Skip to content

Commit

Permalink
Add auto restart for celery
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroAVJ authored Aug 21, 2023
1 parent 9a0e695 commit d555842
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions chirps/base_app/management/commands/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os

from django.core.management.base import BaseCommand
from django.utils import autoreload


class Command(BaseCommand):
Expand All @@ -18,12 +19,13 @@ def add_arguments(self, parser):
def handle(self, *args, **options):
"""Handle the command."""
if options['start']:
self.start()
self.stop()
autoreload.run_with_reloader(self.start)
elif options['stop']:
self.stop()
elif options['restart']:
self.stop()
self.start()
autoreload.run_with_reloader(self.start)

def start(self):
"""Start the celery server."""
Expand Down

0 comments on commit d555842

Please sign in to comment.