Skip to content

Commit

Permalink
Remove celery, redis and flower
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarton committed Mar 7, 2024
1 parent 8e0c312 commit 4610fa8
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 126 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ root.crt

.kube/

# exclude celerybeat-schedule
celerybeat-schedule

# exclude site/ and .cache/ folders anywhere (MkDocs)
*/site/
*/.cache/
Expand Down
6 changes: 0 additions & 6 deletions Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
}
}

# FLOWER monitoring is served from a /flower path
# currently commented out until security is established
# handle /flower* {
# reverse_proxy http://flower:8888
# }

log {
level ERROR # options are DEBUG, INFO, ERROR from most to least verbose
}
Expand Down
Binary file added celerybeat-schedule
Binary file not shown.
35 changes: 1 addition & 34 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ services:
image: e12-django:built # build image and save for use by other containers
depends_on:
- postgis
- redis
command: >
sh -c "python manage.py collectstatic --noinput &&
python manage.py migrate &&
Expand All @@ -48,38 +47,6 @@ services:
- postgis-data:/var/lib/postgresql/data
restart: always

# Redis backend for Celery task scheduler
redis:
image: redis:alpine
expose:
- 6379
restart: always

# Celery worker
celeryworker:
<<: *global # this will inherit config from x-global-environment
image: e12-django:built
command: celery -A rcpch-audit-engine worker -l info
restart: always

# Flower UI for Celery tasks
flower:
<<: *global # this will inherit config from x-global-environment
image: e12-django:built
ports:
- 8888:8888
volumes:
- flower-data:/data
command: celery -A rcpch-audit-engine flower --persistent=True -url_prefix=/flower
restart: always

# Celery scheduled tasks/cron
celerybeat:
<<: *global # this will inherit config from x-global-environment
image: e12-django:built
command: celery -A rcpch-audit-engine beat -l info
restart: always

mkdocs:
<<: *global # this will inherit config from x-global-environment
image: e12-django:built
Expand All @@ -92,5 +59,5 @@ services:

volumes:
caddy-data:
flower-data:
postgis-data:

4 changes: 0 additions & 4 deletions documentation/docs/development/docker-setup-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ Which should result in something like:
```ps title="Powershell terminal"
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
rcpch-audit-engine-caddy-1 caddy "caddy run --config …" caddy 27 minutes ago Up 19 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 443/udp, 2019/tcp
rcpch-audit-engine-celerybeat-1 rcpch-audit-engine-celerybeat "celery -A rcpch-aud…" celerybeat 27 minutes ago Up 19 minutes
rcpch-audit-engine-celeryworker-1 rcpch-audit-engine-celeryworker "celery -A rcpch-aud…" celeryworker 27 minutes ago Up 19 minutes
rcpch-audit-engine-django-1 rcpch-audit-engine-django "sh -c 'python manag…" django 27 minutes ago Up 19 minutes
rcpch-audit-engine-flower-1 rcpch-audit-engine-flower "celery -A rcpch-aud…" flower 27 minutes ago Up 19 minutes 0.0.0.0:8888->8888/tcp
rcpch-audit-engine-mkdocs-1 rcpch-audit-engine-mkdocs "sh -c 'mkdocs build…" mkdocs 27 minutes ago Up 19 minutes 0.0.0.0:8001->8001/tcp
rcpch-audit-engine-postgis-1 postgis/postgis:15-3.3 "docker-entrypoint.s…" postgis 27 minutes ago Up 19 minutes 5432/tcp
rcpch-audit-engine-redis-1 redis:alpine "docker-entrypoint.s…" redis 27 minutes ago Up 19 minutes 6379/tcp
```

Next, type:
Expand Down
9 changes: 0 additions & 9 deletions envs/env-template
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ LETSENCRYPT_EMAIL_ADDRESS="[email protected]" # the email address to send
LETSENCRYPT_ENDPOINT="https://acme-staging-v02.api.letsencrypt.org/directory" # Optionally set to Letsencrypt staging endpoint for testing (https://acme-staging-v02.api.letsencrypt.org/directory)
TLS_SOURCE="internal" # for localhost with SSL, or use "acme" for LetsEncrypt in production

# CELERY
CELERY_BROKER_URL="redis://redis:6379/0"
CELERY_RESULT_BACKEND="redis://redis:6379/0"

# CENSUS PLATFORM (Deprivation Scores)
RCPCH_CENSUS_PLATFORM_TOKEN= # API key for RCPCH Census Platform (Deprivation scoring service API)
RCPCH_CENSUS_PLATFORM_URL="https://api.rcpch.ac.uk/deprivation/v1"
Expand Down Expand Up @@ -51,11 +47,6 @@ EMAIL_HOST_USER= # username for SMTP service
# To output emails to console, set SMTP_EMAIL_ENABLED=False
SMTP_EMAIL_ENABLED=True # To output emails to console, set SMTP_EMAIL_ENABLED=False

# FLOWER
FLOWER_PASSWORD="SET_ME"
FLOWER_PORT=8888
FLOWER_USER="[email protected]"

# HERMES (SNOMED CT)
RCPCH_HERMES_SERVER_URL= # SNOMED server API URL

Expand Down
12 changes: 1 addition & 11 deletions epilepsy12/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
from django.core.mail import send_mail, BadHeaderError
from django.conf import settings

# Third party imports
from celery import shared_task

# E12 Imports
from .general_functions import cohort_number_from_first_paediatric_assessment_date
from epilepsy12.constants import EnumAbstractionLevel
Expand All @@ -21,7 +18,7 @@
# Logging setup
logger = logging.getLogger(__name__)

@shared_task

def send_email_to_recipients(
recipients: list, subject: str, message: str
):
Expand All @@ -40,10 +37,3 @@ def send_email_to_recipients(
except Exception:
raise BadHeaderError

@shared_task
def hello():
"""
THIS IS A SCHEDULED TASK THAT IS CALLED AT 06:00 EVERY DAY
THE CRON DATE/FREQUENCY IS SET IN SETTING.PY
"""
logger.debug("0600 cron check task ran successfully")
3 changes: 0 additions & 3 deletions rcpch-audit-engine/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions rcpch-audit-engine/celery.py

This file was deleted.

27 changes: 0 additions & 27 deletions rcpch-audit-engine/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from pathlib import Path

# third party imports
from celery.schedules import crontab
from django.core.management.utils import get_random_secret_key

# RCPCH imports
Expand Down Expand Up @@ -151,32 +150,6 @@
LOGIN_REDIRECT_URL = "two_factor:profile"
LOGOUT_REDIRECT_URL = "two_factor:login"

# REDIS / Celery
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL")
CELERY_RESULT_BACKEND = os.getenv("CELERY_RESULT_BACKEND")
CELERY_ACCEPT_CONTENT = ["application/json"]
CELERY_TASK_SERIALIZER = "json"
CELERY_RESULT_SERIALIZER = "json"
CELERY_TIMEZONE = "Europe/London"

# CELERY_BEAT_SCHEDULE = {
# "run-daily-at-six-am": {
# "task": "epilepsy12.tasks.hello",
# "schedule": crontab(hour="6", minute=0),
# "options": {
# "expires": 15.0,
# },
# },
# "run-ever-10-seconds": {
# "task": "epilepsy12.tasks.hello",
# "schedule": 10,
# "options": {
# "expires": 15.0,
# },
# },

# }

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
Expand Down
6 changes: 0 additions & 6 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ phonenumbers # though not currently using phonenumbers, this is a dependency of
psycopg2-binary
whitenoise

## scheduled tasks
celery
django-celery-beat
flower
redis

## graphing
plotly

Expand Down
3 changes: 1 addition & 2 deletions templates/epilepsy12/partials/kpis/kpis.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
{% comment %}
This template is the kpis table and is called from selected_trust_kpis, that latter for
open access. The open_access flag passed in from both endpoints denotes this.
Currently the aggregation queries are run with every page load, but in future, the open_access results
will be persisted and run as a cron job once a day.
Currently the aggregation queries are run with every page load.
{% endcomment %}

<div class="sixteen wide column">
Expand Down

0 comments on commit 4610fa8

Please sign in to comment.