From 2c41b17bc47ddf05661b31b46ce8285f66bbc086 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 16 Jul 2019 20:58:10 +0100 Subject: [PATCH] migrate from BROKER_URL to CELERY_BROKER_URL --- docker/install.sh | 2 +- pandora/settings.py | 14 +++++--------- pandora/websocket/worker.py | 2 +- update.py | 11 +++++++++++ vm/pandora_install.sh | 6 +++--- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/docker/install.sh b/docker/install.sh index d1be570f..e1a87181 100755 --- a/docker/install.sh +++ b/docker/install.sh @@ -24,7 +24,7 @@ DATABASES = { 'PORT': 5432, } } -BROKER_URL = "amqp://{0}:{1}@rabbitmq:5672//".format(os.environ.get('RABBITMQ_DEFAULT_USER'), os.environ.get('RABBITMQ_DEFAULT_PASS')) +CELERY_BROKER_URL = "amqp://{0}:{1}@rabbitmq:5672//".format(os.environ.get('RABBITMQ_DEFAULT_USER'), os.environ.get('RABBITMQ_DEFAULT_PASS')) XACCELREDIRECT = True DEBUG = False diff --git a/pandora/settings.py b/pandora/settings.py index 72a48859..1e8f1d56 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -200,7 +200,7 @@ CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_ACCEPT_CONTENT = ['json'] -BROKER_URL = 'amqp://pandora:box@localhost:5672//pandora' +CELERY_BROKER_URL = 'amqp://pandora:box@localhost:5672//pandora' SEND_CELERY_ERROR_EMAILS = False @@ -262,6 +262,10 @@ COLLECTION_ICON = join(SCRIPT_ROOT, 'list_icon.py') DB_GIN_TRGM = False +ALLOWED_HOSTS = ['*'] +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + +DATA_UPLOAD_MAX_MEMORY_SIZE = 32 * 1024 * 1024 RELOADER_RUNNING = False #you can ignore things below this line @@ -293,12 +297,4 @@ except NameError: INSTALLED_APPS = tuple(list(INSTALLED_APPS) + LOCAL_APPS) -ALLOWED_HOSTS = ['*'] -SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') - -DATA_UPLOAD_MAX_MEMORY_SIZE = 32 * 1024 * 1024 -try: - CELERY_BROKER_URL -except NameError: - CELERY_BROKER_URL = BROKER_URL diff --git a/pandora/websocket/worker.py b/pandora/websocket/worker.py index afe0634c..72c35e5a 100644 --- a/pandora/websocket/worker.py +++ b/pandora/websocket/worker.py @@ -27,7 +27,7 @@ class Worker(ConsumerMixin): message.ack() def run(): - with Connection(settings.BROKER_URL) as conn: + with Connection(settings.CELERY_BROKER_URL) as conn: try: worker = Worker(conn) worker.run() diff --git a/update.py b/update.py index 41f322e8..41283454 100755 --- a/update.py +++ b/update.py @@ -261,6 +261,17 @@ if __name__ == "__main__": run('./pandora/manage.py', 'createcachetable') if old <= 6108: run('./bin/pip', 'install', '-r', 'requirements.txt') + if old <= 6160: + run('./bin/pip', 'install', '-r', 'requirements.txt') + with open('pandora/local_settings.py', 'r') as f: + local_settings = f.read() + if 'BROKER_URL' in local_settings and 'CELERY_BROKER_URL' not in local_settings: + local_settings = [ + 'CELERY_' + l if l.startswith('BROKER_URL') else l + for l in local_settings.split('\n') + ] + with open('pandora/local_settings.py', 'w') as f: + f.write('\n'.join(local_settings)) else: if len(sys.argv) == 1: branch = get_branch() diff --git a/vm/pandora_install.sh b/vm/pandora_install.sh index 834060c5..3a62e90d 100755 --- a/vm/pandora_install.sh +++ b/vm/pandora_install.sh @@ -117,9 +117,9 @@ if [ "$RABBITMQ" == "local" ]; then rabbitmqctl add_user pandora $RABBITPWD rabbitmqctl add_vhost /pandora rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*" - BROKER_URL="amqp://pandora:$RABBITPWD@localhost:5672//pandora" + CELERY_BROKER_URL="amqp://pandora:$RABBITPWD@localhost:5672//pandora" else - BROKER_URL="$RABBITMQ" + CELERY_BROKER_URL="$RABBITMQ" fi # checkout pandora from git @@ -145,7 +145,7 @@ DATABASES = { 'PASSWORD': '', } } -BROKER_URL = '$BROKER_URL' +CELERY_BROKER_URL = '$CELERY_BROKER_URL' XACCELREDIRECT = True DEBUG = False