Add some commands to poke the event queue

This commit is contained in:
Trever Fischer
2012-10-22 11:37:47 -04:00
parent dd1dbc7590
commit eec4b8e989
3 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
from django.core.management.base import BaseCommand
from api import events
from minecraft.models import Server
class Command(BaseCommand):
help = 'Display statistics about the event queue'
def handle(self, *args, **options):
servers = Server.objects.all()
for s in servers:
queue = events.server_queue(s)
stats = queue.stats()
print s
for k,v in stats.iteritems():
print "\t%s: %s"%(k, v)
print "\tTubes:"
for t in queue.tubes():
print "\t\t%s"%(t)
next = queue.peek_ready()
if next:
print "\tNext job: %s"%(next.body)
else:
print "\tNo pending job."

View File

@@ -0,0 +1,19 @@
from django.core.management.base import BaseCommand
from api import events
from minecraft.models import Server
class Command(BaseCommand):
help = 'Flush all events from the queue. Probably will break everything.'
def handle(self, *args, **options):
servers = Server.objects.all()
for s in servers:
queue = events.server_queue(s)
stats = queue.stats()
for t in queue.tubes():
queue.watch(t)
job = queue.reserve(0)
while job:
print "Deleting %s: %s"%(job.jid, job.body)
job.delete()
job = queue.reserve(0)

View File

@@ -0,0 +1,11 @@
from django.core.management.base import BaseCommand
from api import events
from minecraft.models import Server
class Command(BaseCommand):
help = 'Send a broadcast event to all configured servers'
def handle(self, *args, **options):
servers = Server.objects.all()
events.server_broadcast(' '.join(args))
print "Event queued."