From f38b1472f9fc5f3abf970a089bd526f4575b661b Mon Sep 17 00:00:00 2001 From: Alexander Trost Date: Sat, 23 Apr 2016 10:59:15 +0200 Subject: [PATCH] This should fix the problems with the slow_queries thing `manage.py process_queue: error: unrecognized arguments: slow_queries` --- Dockerfile | 2 +- .../nagios_plugins/check_queue_worker_errors | 24 ------------------- custom_zulip_files/scripts/lib/install | 6 ++--- custom_zulip_files/zerver/lib/queue.py | 13 +++++----- .../zproject/local_settings_template.py | 3 +++ custom_zulip_files/zproject/settings.py | 5 +--- 6 files changed, 15 insertions(+), 38 deletions(-) delete mode 100755 custom_zulip_files/puppet/zulip/files/nagios_plugins/check_queue_worker_errors diff --git a/Dockerfile b/Dockerfile index f9a3fa4..b185d92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ADD includes/createZulipAdmin.sh /opt/createZulipAdmin.sh RUN rm -rf /root/zulip/puppet && \ cp -rf /root/custom_zulip/* /root/zulip && \ rm -rf /root/custom_zulip && \ - VOYAGER_CLASS="dockervoyager" DEPLOYMENT_TYPE="dockervoyager" ADDITIONAL_PACKAGES="python-dev python-six python-pbs" \ + VOYAGER_CLASS="zulip::dockervoyager" DEPLOYMENT_TYPE="zulip::dockervoyager" ADDITIONAL_PACKAGES="python-dev python-six python-pbs" \ /root/zulip/scripts/setup/install && \ chown zulip:zulip /opt/createZulipAdmin.sh && \ apt-get -qq autoremove --purge -y && \ diff --git a/custom_zulip_files/puppet/zulip/files/nagios_plugins/check_queue_worker_errors b/custom_zulip_files/puppet/zulip/files/nagios_plugins/check_queue_worker_errors deleted file mode 100755 index eacef5b..0000000 --- a/custom_zulip_files/puppet/zulip/files/nagios_plugins/check_queue_worker_errors +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python2.7 - -""" -Nagios plugin to check that none of our queue workers have reported errors. -""" -from __future__ import print_function - -import sys -sys.path.append('/home/zulip/deployments/current') -from zproject import settings - -import glob -import os - -wildcard = os.path.join(settings.QUEUE_ERROR_DIR, '*.errors') -clean = True -for fn in glob.glob(wildcard): - print('WARNING: Queue errors logged in %s' % (fn,)) - clean = False - -if not clean: - sys.exit(1) - -sys.exit(0) diff --git a/custom_zulip_files/scripts/lib/install b/custom_zulip_files/scripts/lib/install index 2f03ea5..283f16a 100755 --- a/custom_zulip_files/scripts/lib/install +++ b/custom_zulip_files/scripts/lib/install @@ -7,8 +7,8 @@ APT_OPTIONS="${APT_OPTIONS:-}" ADDITIONAL_PACKAGES=${ADDITIONAL_PACKAGES:-} # Call the default type "voyager", for docker it's "dockervoyager" DEPLOYMENT_TYPE="${DEPLOYMENT_TYPE:-voyager}" -# Can be for example "dockervoyager" or voyager -VOYAGER_CLASS="${VOYAGER_CLASS:-voyager}" +# Can be for example "zulip::dockervoyager" or "zulip::voyager" +VOYAGER_CLASS="${VOYAGER_CLASS:-zulip::voyager}" # Assumes we've already been untarred @@ -26,7 +26,7 @@ apt-get install -y puppet git python $ADDITIONAL_PACKAGES mkdir -p /etc/zulip -echo -e "[machine]\npuppet_classes = zulip::$VOYAGER_CLASS\ndeploy_type = voyager" > /etc/zulip/zulip.conf +echo -e "[machine]\npuppet_classes = $VOYAGER_CLASS\ndeploy_type = voyager" > /etc/zulip/zulip.conf /root/zulip/scripts/zulip-puppet-apply -f # These server restarting bits should be moveable into puppet-land, ideally diff --git a/custom_zulip_files/zerver/lib/queue.py b/custom_zulip_files/zerver/lib/queue.py index 974543e..988256a 100644 --- a/custom_zulip_files/zerver/lib/queue.py +++ b/custom_zulip_files/zerver/lib/queue.py @@ -11,6 +11,7 @@ import atexit from collections import defaultdict from zerver.lib.utils import statsd +from typing import Any, Callable # This simple queuing library doesn't expose much of the power of # rabbitmq/pika's queuing system; its purpose is to just provide an @@ -19,9 +20,9 @@ from zerver.lib.utils import statsd class SimpleQueueClient(object): def __init__(self): self.log = logging.getLogger('zulip.queue') - self.queues = set() - self.channel = None - self.consumers = defaultdict(set) + self.queues = set() # type: Set[str] + self.channel = None # type: Any + self.consumers = defaultdict(set) # type: Dict[str, Set[Any]] self._connect() def _connect(self): @@ -115,7 +116,7 @@ class SimpleQueueClient(object): def drain_queue(self, queue_name, json=False): "Returns all messages in the desired queue" - messages =[] + messages = [] def opened(): while True: (meta, _, message) = self.channel.basic_get(queue_name) @@ -156,7 +157,7 @@ class TornadoQueueClient(SimpleQueueClient): # https://pika.readthedocs.org/en/0.9.8/examples/asynchronous_consumer_example.html def __init__(self): super(TornadoQueueClient, self).__init__() - self._on_open_cbs = [] + self._on_open_cbs = [] # type: List[Callable[[], None]] def _connect(self, on_open_cb = None): self.log.info("Beginning TornadoQueueClient connection") @@ -230,7 +231,7 @@ class TornadoQueueClient(SimpleQueueClient): lambda: self.channel.basic_consume(wrapped_consumer, queue=queue_name, consumer_tag=self._generate_ctag(queue_name))) -queue_client = None +queue_client = None # type: SimpleQueueClient def get_queue_client(): global queue_client if queue_client is None: diff --git a/custom_zulip_files/zproject/local_settings_template.py b/custom_zulip_files/zproject/local_settings_template.py index 6dac781..bc6cce0 100644 --- a/custom_zulip_files/zproject/local_settings_template.py +++ b/custom_zulip_files/zproject/local_settings_template.py @@ -61,6 +61,9 @@ SSO_APPEND_DOMAIN = None # that account as "less secure": # https://support.google.com/mail/answer/14257. # +# You can quickly test your sending email configuration using: +# ./manage.py send_test_email username@example.com +# # A common problem is hosting providers that block outgoing SMTP traffic. # # With the exception of reading EMAIL_HOST_PASSWORD from diff --git a/custom_zulip_files/zproject/settings.py b/custom_zulip_files/zproject/settings.py index 42e44e2..d0777f6 100644 --- a/custom_zulip_files/zproject/settings.py +++ b/custom_zulip_files/zproject/settings.py @@ -144,7 +144,6 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '', 'INITIAL_PASSWORD_SALT': None, 'FEEDBACK_BOT': 'feedback@zulip.com', 'FEEDBACK_BOT_NAME': 'Zulip Feedback Bot', - 'API_SUPER_USERS': set(), 'ADMINS': '', 'INLINE_IMAGE_PREVIEW': True, 'CAMO_URI': '', @@ -462,12 +461,10 @@ INTERNAL_BOT_DOMAIN = "zulip.com" # Set the realm-specific bot names for bot in INTERNAL_BOTS: - if not bot['var_name'] in vars(): + if vars().get(bot['var_name']) is None: bot_email = bot['email_template'] % (INTERNAL_BOT_DOMAIN,) vars()[bot['var_name'] ] = bot_email -if EMAIL_GATEWAY_BOT not in API_SUPER_USERS: - API_SUPER_USERS.add(EMAIL_GATEWAY_BOT) if EMAIL_GATEWAY_PATTERN != "": EMAIL_GATEWAY_EXAMPLE = EMAIL_GATEWAY_PATTERN % ("support+abcdefg",)