diff --git a/opentech/settings/base.py b/opentech/settings/base.py index d92336480ad301e2424f4627919f1ead832eeae4..e5284296b4e83c753f57949d31ef40e6ba67bacf 100644 --- a/opentech/settings/base.py +++ b/opentech/settings/base.py @@ -82,6 +82,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -201,7 +202,7 @@ SHORT_DATETIME_FORMAT = 'Y-m-d\TH:i:s' # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/stable/howto/static-files/ -STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' STATICFILES_DIRS = [ os.path.join(PROJECT_DIR, 'static_compiled'), diff --git a/opentech/wsgi.py b/opentech/wsgi.py index 4b557f1df1ce3d78016fb7b14c3eed15572b73e6..dce17d69613298fb6fcd29b4483e5409759ea059 100644 --- a/opentech/wsgi.py +++ b/opentech/wsgi.py @@ -9,13 +9,8 @@ https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ import os -from whitenoise.django import DjangoWhiteNoise - from django.core.wsgi import get_wsgi_application -from opentech.wsgi_cron import * # NOQA - - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "opentech.settings.production") -application = DjangoWhiteNoise(get_wsgi_application()) +application = get_wsgi_application() diff --git a/opentech/wsgi_cron.py b/opentech/wsgi_cron.py deleted file mode 100644 index 7ff80257307af022c7967c85c1c7b5784a1c3f51..0000000000000000000000000000000000000000 --- a/opentech/wsgi_cron.py +++ /dev/null @@ -1,38 +0,0 @@ -import os - -from django.core.management import call_command - -try: - import uwsgi - from uwsgidecorators import timer, cron - - print("We have a uWSGI") - has_uwsgi = True -except ImportError: - print("We have no uWSGI") - has_uwsgi = False - - -def single_instance_command(command_name): - """Runs command only on one instance of a uWSGI legion""" - - if uwsgi.i_am_the_lord(os.getenv("CFG_APP_NAME")): - print("I am the lord.") - print("Running %s" % command_name) - call_command(command_name, interactive=False) - else: - print("I am not the lord.") - - -if has_uwsgi: - @cron(0, 1, -1, -1, 0) - def clearsessions(signum): - single_instance_command('clearsessions') - - @cron(0, 0, -1, -1, 0) - def update_index(signum): - single_instance_command('update_index') - - @timer(300) - def publish_scheduled_pages(cron): - single_instance_command('publish_scheduled_pages')