From 310de1acf86d6b9f1821fa1b9f18b901d575b2a4 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 13 Jul 2022 08:21:06 +0100 Subject: [PATCH] Add RQ --- .gitignore | 3 +++ Procfile | 2 ++ justfile | 1 + requirements.txt | 2 ++ website/settings.py | 9 +++++++++ website/urls.py | 1 + 6 files changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index db463d5..a7ea664 100644 --- a/.gitignore +++ b/.gitignore @@ -306,3 +306,6 @@ cython_debug/ /collected-static media/ django-cache/ + +# Redis +dump.rdb diff --git a/Procfile b/Procfile index 69d84d6..14d1ea0 100644 --- a/Procfile +++ b/Procfile @@ -2,3 +2,5 @@ web: ./manage.py runserver watch-js: npm run build:js -- --watch watch-css: npm run build:css -- --watch watch-contrib: ./scripts/copy-npm-contrib.sh; while inotifywait -e modify ./scripts/copy-npm-contrib.sh; do ./scripts/copy-npm-contrib.sh; done +redis: redis-server +rqworker: ./manage.py rqworker --with-scheduler diff --git a/justfile b/justfile index 75a75d6..50d7bf2 100644 --- a/justfile +++ b/justfile @@ -3,6 +3,7 @@ set dotenv-load # Load virtualenv export PATH := justfile_directory() + "/env/bin:" + env_var('PATH') export PYTHONUNBUFFERED := "true" +export QUEUE_STORE_URL := "redis://localhost/0" # Dev environment export DEBUG := "true" diff --git a/requirements.txt b/requirements.txt index 97207da..637b353 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,5 @@ lxml==4.9.0 more-itertools==8.13.0 requests==2.27.1 wagtail-generic-chooser==0.4.1 +django-rq==2.5.1 +django-redis==5.2.0 diff --git a/website/settings.py b/website/settings.py index 15b07c0..9c8ddc3 100644 --- a/website/settings.py +++ b/website/settings.py @@ -45,6 +45,7 @@ INSTALLED_APPS = [ "modelcluster", "taggit", "generic_chooser", + "django_rq", "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", @@ -94,6 +95,14 @@ DATABASES = {"default": env.db(default=f"sqlite:///{BASE_DIR}/db.sqlite3")} CACHES = {"default": env.cache(default=f"filecache:///{BASE_DIR}/django-cache")} +RQ_QUEUES = {} + +USE_REDIS_QUEUE = False +if queue_store := env.cache("QUEUE_STORE_URL", default=None): + CACHES["rq"] = queue_store + USE_REDIS_QUEUE = True + RQ_QUEUES["default"] = {"USE_REDIS_CACHE": "rq"} + # Internationalization # https://docs.djangoproject.com/en/4.0/topics/i18n/ diff --git a/website/urls.py b/website/urls.py index 7644ea4..0277ba0 100644 --- a/website/urls.py +++ b/website/urls.py @@ -22,6 +22,7 @@ urlpatterns = [ ServeView.as_view(action="redirect"), name="wagtailimages_serve", ), + path("django-rq/", include("django_rq.urls")), ]