diff --git a/scripts/setup/configure-rabbitmq b/scripts/setup/configure-rabbitmq index e9ea28b008..0e7711dd01 100755 --- a/scripts/setup/configure-rabbitmq +++ b/scripts/setup/configure-rabbitmq @@ -10,6 +10,7 @@ set -eu RABBITMQ_USERNAME=$("$(dirname "$0")/../get-django-setting" RABBITMQ_USERNAME) RABBITMQ_PASSWORD=$("$(dirname "$0")/../get-django-setting" RABBITMQ_PASSWORD) +RABBITMQ_VHOST=$("$(dirname "$0")/../get-django-setting" RABBITMQ_VHOST) rabbitmqctl await_startup rabbitmqctl delete_user "$RABBITMQ_USERNAME" || true @@ -17,4 +18,7 @@ rabbitmqctl delete_user zulip || true rabbitmqctl delete_user guest || true rabbitmqctl add_user "$RABBITMQ_USERNAME" "$RABBITMQ_PASSWORD" rabbitmqctl set_user_tags "$RABBITMQ_USERNAME" administrator -rabbitmqctl set_permissions -p / "$RABBITMQ_USERNAME" '.*' '.*' '.*' +if ! rabbitmqctl list_vhosts --no-table-headers --quiet | grep -qx "$RABBITMQ_VHOST"; then + rabbitmqcql add_vhost "$RABBITMQ_VHOST" +fi +rabbitmqctl set_permissions -p "$RABBITMQ_VHOST" "$RABBITMQ_USERNAME" '.*' '.*' '.*' diff --git a/zerver/lib/queue.py b/zerver/lib/queue.py index 0aee5cd12e..e7966733ef 100644 --- a/zerver/lib/queue.py +++ b/zerver/lib/queue.py @@ -89,6 +89,7 @@ class QueueClient(Generic[ChannelT], metaclass=ABCMeta): return pika.ConnectionParameters( settings.RABBITMQ_HOST, port=settings.RABBITMQ_PORT, + virtual_host=settings.RABBITMQ_VHOST, heartbeat=self.rabbitmq_heartbeat, tcp_options=tcp_options, ssl_options=ssl_options, diff --git a/zproject/default_settings.py b/zproject/default_settings.py index 651b79087d..303e3c8550 100644 --- a/zproject/default_settings.py +++ b/zproject/default_settings.py @@ -191,6 +191,7 @@ MEMCACHED_LOCATION = "127.0.0.1:11211" MEMCACHED_USERNAME = None if get_secret("memcached_password") is None else "zulip@localhost" RABBITMQ_HOST = "127.0.0.1" RABBITMQ_PORT = 5672 +RABBITMQ_VHOST = "/" RABBITMQ_USERNAME = "zulip" RABBITMQ_USE_TLS = False REDIS_HOST = "127.0.0.1" diff --git a/zproject/prod_settings_template.py b/zproject/prod_settings_template.py index d1fcc9be2d..63d3c0408b 100644 --- a/zproject/prod_settings_template.py +++ b/zproject/prod_settings_template.py @@ -606,6 +606,8 @@ SOCIAL_AUTH_SAML_SUPPORT_CONTACT = { ## optionally RABBITMQ_PORT, to the hostname and port here. # RABBITMQ_HOST = "127.0.0.1" # RABBITMQ_PORT = 5672 +## To use a different RabbitMQ "virtual host", adjust this. +# RABBITMQ_VHOST = "/" ## To use another RabbitMQ user than the default "zulip", set RABBITMQ_USERNAME here. # RABBITMQ_USERNAME = "zulip" ## To access the RabbitMQ server over TLS, set this to True; this is