Skip to content

Commit

Permalink
Merge pull request #170 from PedroAVJ/add_auto_restart_for_celery
Browse files Browse the repository at this point in the history
Add auto restart for celery
  • Loading branch information
zimventures authored Aug 21, 2023
2 parents 878ec37 + 617393e commit a9dc640
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ The chirps application makes use of Celery and RabbitMQ for job processing. Exec

Both the rabbitmq and celery commands have `--stop` and `--restart` options as well.

#### IMPORTANT CELERY TIP

If you make changes to a Celery task, it must be restarted in order for those changes to be picked up. Simply run
`./manage.py celery --restart`

### Run Webserver

`./manage.py runserver`
Expand Down
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 a9dc640

Please sign in to comment.