diff --git a/MUOR/MUOR/configs/loader.html b/MUOR/MUOR/configs/loader.html
new file mode 100644
index 000000000..176f6703e
--- /dev/null
+++ b/MUOR/MUOR/configs/loader.html
@@ -0,0 +1,51 @@
+
+
+
+
+
+ MultiUserOpenRefine}
+
+
+
+
+
+
+
+
![logo](static/images/logo.png)
+
+ MultiUserOpenRefine
+
+
Your instance is getting
+ ready. Please wait...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MUOR/MUOR/settings.py b/MUOR/MUOR/settings.py
index efdfe671f..b9669c02f 100644
--- a/MUOR/MUOR/settings.py
+++ b/MUOR/MUOR/settings.py
@@ -25,7 +25,7 @@ SECRET_KEY = 'django-insecure-t52#vo-k9ty*$@u9bf75hrkd#^o_)gadrz9$7w%xnkb-0#y!bi
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
-ALLOWED_HOSTS = ['django']
+ALLOWED_HOSTS = ['django', 'localhost']
# Application definition
@@ -126,7 +126,7 @@ STATICFILES_DIRS = (
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
-LOGIN_REDIRECT_URL = 'loader'
+LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'
# Default primary key field type
@@ -141,4 +141,14 @@ AVAILABLE_PORTS_RANGE = (6000, 7000)
DOCKER_IMAGE = 'openrefine:latest'
+SESSION_EXPIRE_AT_BROWSER_CLOSE = True
+SESSION_COOKIE_AGE = 60 * 60
+CELERY_BROKER_URL = 'redis+socket:///var/run/redis/redis-server.sock'
+CELERY_TIMEZONE = "Europe/Warsaw"
+CELERY_BEAT_SCHEDULE = {
+ 'daily_report': {
+ 'task': 'clear_sessions',
+ 'schedule': 60,
+ }
+}
diff --git a/MUOR/MUOR/signals.py b/MUOR/MUOR/signals.py
index 10f734117..a2e424835 100644
--- a/MUOR/MUOR/signals.py
+++ b/MUOR/MUOR/signals.py
@@ -1,10 +1,11 @@
-from django.db.models.signals import post_save
+from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
from .DockerManager import DockerManager
from .NGINXConfigurator import NGINXConfigurator
from .models import Profile, Session
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.conf import settings
+from django.contrib.sessions.models import Session as DjangoSession
def get_sessions_data():
@@ -57,11 +58,11 @@ def profile_start_up(sender, user, request, **kwargs):
NGINXConfigurator.refresh_config(get_sessions_data())
-@receiver(user_logged_out)
-def profile_logged_out(sender, user, request, **kwargs):
+@receiver(pre_delete, sender=DjangoSession)
+def close_session(sender, instance, **kwargs):
# Obtaining container_id
try:
- session = Session.objects.get(user=user)
+ session = Session.objects.get(sessionid=instance.session_key)
container_id = session.container_id
# Turn off and delete container
@@ -70,6 +71,7 @@ def profile_logged_out(sender, user, request, **kwargs):
# Delete session
session.delete()
+ print("Closed session!")
except Session.DoesNotExist:
pass
NGINXConfigurator.refresh_config(get_sessions_data())
diff --git a/MUOR/MUOR/tasks.py b/MUOR/MUOR/tasks.py
new file mode 100644
index 000000000..50a478293
--- /dev/null
+++ b/MUOR/MUOR/tasks.py
@@ -0,0 +1,7 @@
+from celery import shared_task
+from django.core import management
+
+
+@shared_task(name="clear_sessions")
+def clear_sessions():
+ management.call_command('clearsessions')
diff --git a/MUOR/MUOR/urls.py b/MUOR/MUOR/urls.py
index 4a143369b..b4251c028 100644
--- a/MUOR/MUOR/urls.py
+++ b/MUOR/MUOR/urls.py
@@ -25,7 +25,6 @@ urlpatterns = [
path('admin/', admin.site.urls),
path('', include('django.contrib.auth.urls')),
path('signup/', SignUpView.as_view(), name='signup'),
- path('loader/', TemplateView.as_view(template_name='loader.html'), name='loader'),
path('welcome/', TemplateView.as_view(template_name='home.html'), name='home'),
path('favicon.ico', RedirectView.as_view(url=staticfiles_storage.url('images/favicon.ico'))),
path('', views.home, name='home')
diff --git a/MUOR/requirements.txt b/MUOR/requirements.txt
index a5638b509..da14598fc 100644
--- a/MUOR/requirements.txt
+++ b/MUOR/requirements.txt
@@ -1,4 +1,7 @@
Django
django-crispy-forms
docker
-uwsgi
\ No newline at end of file
+uwsgi
+celery
+redis
+django-redis
diff --git a/MUOR/templates/loader.html b/MUOR/templates/loader.html
deleted file mode 100644
index 6702a8658..000000000
--- a/MUOR/templates/loader.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-{% extends 'base.html' %}
-
-{% block title %}Loader{% endblock %}
-
-{% block content %}
- Your instance is getting ready. Please wait...
-
-{% endblock %}
\ No newline at end of file