Add some commands to poke the event queue
This commit is contained in:
23
api/management/commands/event_stats.py
Normal file
23
api/management/commands/event_stats.py
Normal 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."
|
19
api/management/commands/flush_events.py
Normal file
19
api/management/commands/flush_events.py
Normal 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)
|
11
api/management/commands/server_broadcast.py
Normal file
11
api/management/commands/server_broadcast.py
Normal 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."
|
Reference in New Issue
Block a user