Files
zulip/zephyr/management/commands/process_user_activity.py
Tim Abbott e592e71515 [manual] Use rabbitmq queue to process UserActivity.
Before this is deployed, we need to install rabbitmq and pika on the
target server (see the puppet part of this commit for how).

When this is deployed, we need to start the new user activity bot:

./manage.py process_user_activity

in the screen session on the relevant server, or user_activity logs
won't be processed (which will eventually result in all users getting
notifications about how their mirrors are out of date).

(imported from commit 44d605aca0290bef2c94fb99267e15e26b21673b)
2013-01-14 13:28:23 -05:00

23 lines
743 B
Python

from optparse import make_option
from django.core.management.base import BaseCommand
import simplejson
import pika
from zephyr.lib.actions import process_user_activity_event
from zephyr.lib.queue import SimpleQueue
class Command(BaseCommand):
option_list = BaseCommand.option_list
help = "Process UserActivity log messages."
def handle(self, *args, **options):
activity_queue = SimpleQueue()
def callback(ch, method, properties, event):
print " [x] Received %r" % (event,)
process_user_activity_event(event)
print ' [*] Waiting for messages. To exit press CTRL+C'
activity_queue.register_json_consumer('user_activity', callback)
activity_queue.start_consuming()