From 35d978d4c24b25d4300c58b26957b833c7a18b83 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 26 Nov 2014 21:03:27 +0100 Subject: [PATCH] migrate celery settings to BROKER_URL --- pandora/settings.py | 7 ++----- update.py | 19 +++++++++++++++++++ vm/firstboot.sh | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pandora/settings.py b/pandora/settings.py index 0ad4af0f..f232f2f3 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -170,11 +170,8 @@ DATABASES = { #rabbitmq connection settings CELERY_RESULT_BACKEND = "database" -BROKER_HOST = "127.0.0.1" -BROKER_PORT = 5672 -BROKER_USER = "pandora" -BROKER_PASSWORD = "box" -BROKER_VHOST = "/pandora" +BROKER_URL = 'amqp://pandora:box@localhost:5672//pandora' + SEND_CELERY_ERROR_EMAILS = False #with apache x-sendfile or lighttpd set this to True diff --git a/update.py b/update.py index d9da9da9..ade41782 100755 --- a/update.py +++ b/update.py @@ -102,6 +102,25 @@ if __name__ == "__main__": run('./bin/pip', 'install', '-r', 'requirements.txt') if old < 4379: run('./bin/pip', 'install', '-r', 'requirements.txt') + if old < 4549: + import pandora.settings + with open('pandora/local_settings.py', 'r') as f: + local_settings = f.read() + if not 'BROKER_URL' in local_settings: + broker_url = 'amqp://%s:%s@%s:%s/%s' % ( + getattr(pandora.settings, 'BROKER_USER', 'pandora'), + getattr(pandora.settings, 'BROKER_PASSWORD', 'box'), + getattr(pandora.settings, 'BROKER_HOST', '127.0.0.1'), + getattr(pandora.settings, 'BROKER_PORT', 5672), + getattr(pandora.settings, 'BROKER_VHOST', '/pandora'), + ) + local_settings = [ + l for l in local_settings.split('\n') if not l.startswith('BROKER_') + ] + [ + 'BROKER_URL = "%s"' % broker_url, '' + ] + with open('pandora/local_settings.py', 'w') as f: + f.write('\n'.join(local_settings)) else: if len(sys.argv) == 1: diff --git a/vm/firstboot.sh b/vm/firstboot.sh index bfeaee33..01c90a70 100755 --- a/vm/firstboot.sh +++ b/vm/firstboot.sh @@ -128,7 +128,7 @@ DATABASES = { 'PASSWORD': '', } } -BROKER_PASSWORD = "$RABBITPWD" +BROKER_URL = 'amqp://pandora:$RABBITPWD@localhost:5672//pandora' XACCELREDIRECT = True DEBUG = False