From c0607297c7d2102ec1ddcbde8f0ade5b2fa09c3c Mon Sep 17 00:00:00 2001 From: Tomas Gavenciak Date: Thu, 17 Sep 2015 18:27:44 +0200 Subject: [PATCH] Fix for permissions, fix exception handling (WSGI) --- Makefile | 4 ++-- mamweb/wsgi.py | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 12b49069..01f7790a 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ deploy_test: ./manage.py migrate ./manage.py collectstatic --noinput (chown -Rf :mam . || true ) - (chmod -Rf g+w . || true ) + (chmod -Rf g+rwX . || true ) touch mamweb/wsgi.py @echo Done. @@ -84,7 +84,7 @@ deploy_prod: ./manage.py migrate ./manage.py collectstatic --noinput (chown -Rf :mam . || true ) - (chmod -Rf g+w . || true ) + (chmod -Rf g+rwX . || true ) touch mamweb/wsgi.py @echo Done. diff --git a/mamweb/wsgi.py b/mamweb/wsgi.py index 7db4cb54..fa13a197 100644 --- a/mamweb/wsgi.py +++ b/mamweb/wsgi.py @@ -7,21 +7,22 @@ For more information on this file, see https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ """ -import sys, os, os.path, traceback, time +import sys, os, os.path, traceback, time, signal os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mamweb.settings") -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'lib', 'python2.7', 'site-packages')) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'lib', 'python2.7', 'site-packages'))) -from django.core.wsgi import get_wsgi_application try: + from django.core.wsgi import get_wsgi_application application = get_wsgi_application() + except Exception: print 'handling WSGI exception' # Error loading applications if 'mod_wsgi' in sys.modules: traceback.print_exc() os.kill(os.getpid(), signal.SIGINT) - time.sleep(10) + time.sleep(2)