diff --git a/celery_dev.sh b/celery_dev.sh new file mode 100755 index 00000000..74fe3d21 --- /dev/null +++ b/celery_dev.sh @@ -0,0 +1,5 @@ +export REDIS_HOST=redis +export REDIS_PORT=6379 + +celery --app=service:celery beat --loglevel=INFO & +celery --app=service:celery worker --loglevel=INFO & diff --git a/entrypoint.sh b/entrypoint.sh index bb2fd405..41a5aa39 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,8 +4,9 @@ redis-server --daemonize yes # Run celery beat and worker -celery beat --app=service:celery --loglevel=INFO & -celery worker --app=service:celery --loglevel=INFO & +celery --app=service:celery beat --loglevel=INFO & +celery --app=service:celery worker --loglevel=INFO & # Run the gunicorn server -exec gunicorn -b :8000 --timeout 300 --graceful-timeout 60 --access-logfile - --error-logfile - service:app +#exec gunicorn -b :8000 --certfile=service.crt --keyfile=service.key --timeout 300 --graceful-timeout 60 --access-logfile - --error-logfile - service:app +exec gunicorn -b :8000 --timeout 300 --graceful-timeout 60 --access-logfile - --error-logfile - service:app diff --git a/platipy/backend/application.py b/platipy/backend/application.py index a49c99d8..680d8d85 100644 --- a/platipy/backend/application.py +++ b/platipy/backend/application.py @@ -14,13 +14,8 @@ import json import os -import tempfile from flask import Flask -from celery import current_app -from celery.bin import worker -from celery.bin import beat -from multiprocessing import Process from loguru import logger import pydicom @@ -57,42 +52,6 @@ def decorator(f): return decorator - def run_celery(self): - - if self.celery_started: - return - - application = current_app._get_current_object() - - celery_worker = worker.worker(app=application) - - options = { - "broker": self.config["CELERY_BROKER_URL"], - "loglevel": "INFO", - "traceback": True, - } - - celery_worker.run(**options) - - def run_beat(self): - - if self.beat_started: - return - - application = current_app._get_current_object() - - celery_beat = beat.beat(app=application) - - options = { - "broker": self.config["CELERY_BROKER_URL"], - "loglevel": "INFO", - "traceback": True, - "beat": True, - "schedule": os.path.join(str(tempfile.mkdtemp()), "celery-beat-schedule"), - } - - celery_beat.run(**options) - def run( self, host=None, @@ -106,14 +65,6 @@ def run( logger.info("Starting APP!") - process_celery = Process(target=self.run_celery) - process_celery.start() - self.celery_started = True - - process_beat = Process(target=self.run_beat) - process_beat.start() - self.beat_started = True - self.dicom_listener_port = dicom_listener_port self.dicom_listener_aetitle = dicom_listener_aetitle @@ -128,9 +79,6 @@ def run( **options ) - process_celery.join() - process_beat.join() - def run_dicom_listener(self, listen_port, listen_ae_title): """ Background task that listens at a specific port for incoming dicom series diff --git a/requirements-backend.txt b/requirements-backend.txt index f4998c97..dc60968c 100644 --- a/requirements-backend.txt +++ b/requirements-backend.txt @@ -1,7 +1,7 @@ flask >= 1.1.2 flask-restful >= 0.3.8 flask-sqlalchemy >= 2.4.4 -celery >= 4.4.7,< 5.0.0 +celery >= 5.2.3 redis >= 3.5.3 psutil >= 5.8.0 gunicorn >= 20.0.4