diff --git a/web/docker-entrypoint.sh b/web/docker-entrypoint.sh index 3b8cd98..69111f4 100755 --- a/web/docker-entrypoint.sh +++ b/web/docker-entrypoint.sh @@ -16,7 +16,15 @@ function wait_for_postgres () { function wait_for_mysql () { # Check if MySQL is up and accepting connections. - HOSTNAME=$(python -c "from urllib.parse import urlparse; o = urlparse('$DATABASE_URL'); print(o.hostname);") + HOSTNAME=$(python <&2 echo "MySQL is unavailable - sleeping" sleep 1 diff --git a/web/mailman-web/settings.py b/web/mailman-web/settings.py index cbeaaf6..2274934 100644 --- a/web/mailman-web/settings.py +++ b/web/mailman-web/settings.py @@ -29,6 +29,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/ import os import socket import dj_database_url +import sys BASE_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -99,8 +100,7 @@ INSTALLED_APPS = ( 'allauth.socialaccount.providers.google', ) - -MIDDLEWARE = ( +_MIDDLEWARE = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -114,6 +114,14 @@ MIDDLEWARE = ( 'postorius.middleware.PostoriusMiddleware', ) +# Use old-style Middleware class in Python 2 and released versions of +# Django-mailman3 don't support new style middlewares. + +if sys.version_info < (3, 0): + MIDDLEWARE_CLASSES = _MIDDLEWARE +else: + MIDDLEWARE = _MIDDLEWARE + ROOT_URLCONF = 'urls'