diff --git a/SciPost_v1/settings/base.py b/SciPost_v1/settings/base.py index eb4f73096dc327b25fa0d2687c14e45ad6f3b6f6..13797a0598b7b5263b0cf30a1489a08e60573eca 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 ef15b901964646f3d808284beffb47e5fc94ac63..260432d73227af78b5790134ae027234ff36870d 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 4e44249659a7d36864308b1b734d7356a24295b7..3475572dd6643c0cc13e804eba5896871ec4aeb5 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 efdec24ed6a58c2b28dbec591c325d3a752c4082..bcb1b4c287f52665b031a00d876ac9fb7560133a 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.