From d555842585bbd01b9adc86c94967941f61126363 Mon Sep 17 00:00:00 2001 From: PedroAVJ <109568868+PedroAVJ@users.noreply.github.com> Date: Mon, 21 Aug 2023 16:30:41 +0000 Subject: [PATCH] Add auto restart for celery --- chirps/base_app/management/commands/celery.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chirps/base_app/management/commands/celery.py b/chirps/base_app/management/commands/celery.py index fb6e2822..9f3de31a 100644 --- a/chirps/base_app/management/commands/celery.py +++ b/chirps/base_app/management/commands/celery.py @@ -2,6 +2,7 @@ import os from django.core.management.base import BaseCommand +from django.utils import autoreload class Command(BaseCommand): @@ -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."""