mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
Add TestWorker queue processor.
TestWorker is for troubleshooting, and it simply appends lines to a file in /tmp. (imported from commit 96b646a193a5474f3222b41725742e359b5301ec)
This commit is contained in:
@@ -254,3 +254,15 @@ class DigestWorker(QueueProcessingWorker):
|
||||
logging.info("Received digest event: %s" % (event,))
|
||||
handle_digest_email(event["user_profile_id"], event["cutoff"])
|
||||
|
||||
@assign_queue('test')
|
||||
class TestWorker(QueueProcessingWorker):
|
||||
# This worker allows you to test the queue worker infrastructure without
|
||||
# creating significant side effects. It can be useful in development or
|
||||
# for troubleshooting prod/staging. It pulls a message off the test queue
|
||||
# and appends it to a file in /tmp.
|
||||
def consume(self, ch, method, properties, event):
|
||||
fn = settings.ZULIP_WORKER_TEST_FILE
|
||||
message = ujson.dumps(event)
|
||||
logging.info("TestWorker should append this message to %s: %s" % (fn, message))
|
||||
with open(fn, 'a') as f:
|
||||
f.write(message + '\n')
|
||||
|
||||
@@ -522,6 +522,9 @@ else:
|
||||
QUEUE_ERROR_DIR = 'queue_error'
|
||||
|
||||
|
||||
ZULIP_WORKER_TEST_FILE = '/tmp/zulip-worker-test-file'
|
||||
|
||||
|
||||
if len(sys.argv) > 2 and sys.argv[0].endswith('manage.py') and sys.argv[1] == 'process_queue':
|
||||
FILE_LOG_PATH = WORKER_LOG_PATH
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user