From de4ac4dadddd8d7840b305692ac5e913f03832dc Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Mon, 27 Jul 2015 22:04:57 +0100 Subject: [PATCH] Celery and stuff --- Dockerfile | 4 ++++ api/auth.py | 6 ++++-- api/views.py | 5 ++++- dss/settings.py | 1 - 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f7d9704..a81128d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,3 +13,7 @@ WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/ + +RUN adduser --disabled-password --gecos '' djworker +RUN chown djworker /files -R +RUN chown djworker /srv/logs -R diff --git a/api/auth.py b/api/auth.py index 4246dd8..0403173 100644 --- a/api/auth.py +++ b/api/auth.py @@ -1,5 +1,6 @@ from calendar import timegm import datetime +import logging from rest_framework import permissions from rest_framework.authtoken.serializers import AuthTokenSerializer from rest_framework.response import Response @@ -15,7 +16,7 @@ from rest_framework import parsers from social.apps.django_app.utils import psa from dss import settings - +logger = logging.getLogger('spa') @psa() def auth_by_token(request, backend): user = request.backend.do_auth( @@ -36,9 +37,10 @@ class FacebookView(APIView): try: user = auth_by_token(request, backend) except Exception, e: + logger.exception(e) return Response({ 'status': 'Bad request', - 'message': 'Could not authenticate with the provided token' if not settings.DEBUG else e.message + 'message': e.message }, status=status.HTTP_400_BAD_REQUEST) if user: diff --git a/api/views.py b/api/views.py index 5a70774..1ab0fad 100755 --- a/api/views.py +++ b/api/views.py @@ -181,12 +181,15 @@ class PartialMixUploadView(views.APIView): # Chain the waveform & archive tasks together # Probably not the best place for them but will do for now # First argument to archive_mix_task is not specified as it is piped from create_waveform_task + + logger.debug("Processing input_file: {0}".format(input_file)) + logger.debug("Connecting to broker: {0}".format(settings.BROKER_URL)) (create_waveform_task.s(input_file, uid) | archive_mix_task.s(filetype='mp3', uid=uid)).delay() logger.debug("Waveform task started") except Exception, ex: - logger.error("Unable to connect to rabbitmq: {0}".format(ex.message)) + logger.exception(ex) response = \ 'Unable to connect to rabbitmq, there may be a delay in getting your mix online' diff --git a/dss/settings.py b/dss/settings.py index 6cfb3c8..2904ec6 100755 --- a/dss/settings.py +++ b/dss/settings.py @@ -139,7 +139,6 @@ LOGOUT_URL = reverse_lazy('home') FACEBOOK_APP_ID = '154504534677009' -djcelery.setup_loader() AVATAR_STORAGE_DIR = MEDIA_ROOT + '/avatars/' ACCOUNT_LOGOUT_REDIRECT_URL = '/'