From 782899fae35f23cba7499fce76858e1916442bfe Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Wed, 9 Jan 2019 09:01:39 +0100 Subject: [PATCH] Link flower --- SciPost_v1/settings/base.py | 3 ++- SciPost_v1/settings/production.py | 3 --- scipost/urls.py | 1 + scipost/views.py | 10 ++++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/SciPost_v1/settings/base.py b/SciPost_v1/settings/base.py index eb4f73096..13797a059 100644 --- a/SciPost_v1/settings/base.py +++ b/SciPost_v1/settings/base.py @@ -379,8 +379,9 @@ LOGGING = { # Celery scheduled tasks CELERY_RESULT_BACKEND = 'django-db' -CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672//' +CELERY_BROKER_URL = get_secret('CELERY_BROKER_URL') CELERY_IMPORTS = ('submissions.tasks', ) +FLOWER_PORT = get_secret('FLOWER_PORT') # Automation. diff --git a/SciPost_v1/settings/production.py b/SciPost_v1/settings/production.py index ef15b9019..260432d73 100644 --- a/SciPost_v1/settings/production.py +++ b/SciPost_v1/settings/production.py @@ -53,6 +53,3 @@ ITHENTICATE_PASSWORD = get_secret('ITHENTICATE_PASSWORD') # Logging LOGGING['handlers']['scipost_file_arxiv']['filename'] = '/home/scipost/webapps/scipost/logs/arxiv.log' LOGGING['handlers']['scipost_file_doi']['filename'] = '/home/scipost/webapps/scipost/logs/doi.log' - -# Celery scheduled tasks -CELERY_BROKER_URL = get_secret('CELERY_BROKER_URL') diff --git a/scipost/urls.py b/scipost/urls.py index 4e4424965..3475572dd 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -19,6 +19,7 @@ JOURNAL_REGEX = '(?P<doi_label>%s)' % REGEX_CHOICES urlpatterns = [ url(r'^$', views.index, name='index'), + url(r'^flower/', views.flower, name='flower'), # monitor for Celery tasks; su only url(r'^files/secure/(?P<path>.*)$', views.protected_serve, name='secure_file'), # General use pages diff --git a/scipost/views.py b/scipost/views.py index efdec24ed..bcb1b4c28 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -129,6 +129,16 @@ def index(request): return render(request, 'scipost/index.html', context) +def flower(request): + """ + Monitoring pages for the Celery-driven scheduled tasks. + This view is accessible to superusers only. + """ + if not request.user.is_authenticated or not request.user.is_superuser: + raise Http404 + return redirect('https://localhost:%s' % settings.FLOWER_PORT) + + def protected_serve(request, path, show_indexes=False): """ Serve media files from outside the public MEDIA_ROOT folder. -- GitLab