Celery and stuff

This commit is contained in:
Fergal Moran
2015-07-27 22:04:57 +01:00
parent 69c779c90e
commit de4ac4dadd
4 changed files with 12 additions and 4 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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'

View File

@@ -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 = '/'