Search code examples
pythondjango-celerydotcloud

Why do I get a login prompt when I deploy the django-celery example app on dotcloud?


I've been struggling to get the demo application in django-celery working on dotcloud. I have looked at the tutorial at http://docs.dotcloud.com/0.9/tutorials/python/django-celery/ but it isn't a great deal of help.

The example application is a Django 1.4 app. I'm not sure why, but when I navigate to the deployed application, instead of the index page it presents me with a username password popup. The message in the popup is

The server at TheDomain requires a username and password. The server says: RabbitMQ Management.

Does anyone know why this behaviour has been added?

The differences from the django-celery example app are:

# Django settings for project in settings.py

import os
import json
import djcelery

# Load the dotCloud environment
with open('/home/dotcloud/environment.json') as f:
  dotcloud_env = json.load(f)

# Configure Celery using the RabbitMQ credentials found in the dotCloud
# environment.
djcelery.setup_loader()
BROKER_HOST = dotcloud_env['DOTCLOUD_BROKER_AMQP_HOST']
BROKER_PORT = int(dotcloud_env['DOTCLOUD_BROKER_AMQP_PORT'])
BROKER_USER = dotcloud_env['DOTCLOUD_BROKER_AMQP_LOGIN']
BROKER_PASSWORD = dotcloud_env['DOTCLOUD_BROKER_AMQP_PASSWORD']
BROKER_VHOST = '/'

Instead of the database settings in the app - I've replaced the database settings with.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'template1',
        'USER': dotcloud_env['DOTCLOUD_DB_SQL_LOGIN'],
        'PASSWORD': dotcloud_env['DOTCLOUD_DB_SQL_PASSWORD'],
        'HOST': dotcloud_env['DOTCLOUD_DB_SQL_HOST'],
        'PORT': int(dotcloud_env['DOTCLOUD_DB_SQL_PORT']),
    }
}

I've also added a requirements.txt file with

Django==1.4
django-celery
setproctitle

and the dotcloud.yml file

www:
    type: python

broker:
    type: rabbitmq

workers:
    type: python-worker

db:
    type: postgresql

and the supervisor.conf

[program:djcelery]
directory = $HOME/current/
command = python manage.py celeryd -E -l info -c 2
stderr_logfile = /var/log/supervisor/%(program_name)s_error.log
stdout_logfile = /var/log/supervisor/%(program_name)s.log

[program:celerycam]
directory = $HOME/current/
command = python manage.py celerycam
stderr_logfile = /var/log/supervisor/%(program_name)s_error.log
stdout_logfile = /var/log/supervisor/%(program_name)s.log

and to the postinstall file I added

dotcloud_get_env() {
    sed -n "/$1/ s/.*: \"\(.*\)\".*/\1/p" < "$HOME/environment.json"
}

setup_django_celery() {
    cat > $HOME/current/supervisord.conf << EOF
[program:djcelery]
directory = $HOME/current/
command = python manage.py celeryd -E -l info -c 2
stderr_logfile = /var/log/supervisor/%(program_name)s_error.log
stdout_logfile = /var/log/supervisor/%(program_name)s.log

[program:celerycam]
directory = $HOME/current/
command = python manage.py celerycam
stderr_logfile = /var/log/supervisor/%(program_name)s_error.log
stdout_logfile = /var/log/supervisor/%(program_name)s.log
EOF
}

if [ `dotcloud_get_env SERVICE_NAME` = workers ] ; then
    setup_django_celery
fi

the last fi was added but not in the dotcloud tutorial.

Edit

I've whipped together a repo with this example, as when it works it should be quite useful for others. It's available at: https://github.com/asunwatcher/django-celery-dotcloud


Solution

  • This looks like an error in our CLI. Try dotcloud url and you will see that your application has two URLs, one for your www service and one for your rabbitMQ, which is a rabbit management interface. You can log in there with the rabbit user name and password given in the dotCloud environment.

    For some reason we're picking the wrong one to show you at the end of the push. The url for your www service is the one you want.