Skip to content

Commit

Permalink
Merge branch 'Aninstance-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Koed00 committed Apr 5, 2017
2 parents f3ae8a8 + e844225 commit d92f542
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 11 additions & 2 deletions django_q/management/commands/qinfo.py
Expand Up @@ -3,7 +3,7 @@

from django_q import VERSION
from django_q.conf import Conf
from django_q.monitor import info
from django_q.monitor import info, get_ids


class Command(BaseCommand):
Expand All @@ -18,9 +18,18 @@ def add_arguments(self, parser):
default=False,
help='Print current configuration.',
)
parser.add_argument(
'--ids',
action='store_true',
dest='ids',
default=False,
help='Print cluster task ID(s) (PIDs).',
)

def handle(self, *args, **options):
if options.get('config', False):
if options.get('ids', True):
get_ids()
elif options.get('config', False):
hide = ['conf', 'IDLE', 'STOPPING', 'STARTING', 'WORKING', 'SIGNAL_NAMES', 'STOPPED']
settings = [a for a in dir(Conf) if not a.startswith('__') and a not in hide]
self.stdout.write('VERSION: {}'.format('.'.join(str(v) for v in VERSION)))
Expand Down
11 changes: 11 additions & 0 deletions django_q/monitor.py
Expand Up @@ -187,3 +187,14 @@ def info(broker=None):
term.white('{0:.4f}'.format(exec_time))
)
return True


def get_ids():
# prints id (PID) of running clusters
stat = Stat.get_all()
if stat:
for s in stat:
print(s.cluster_id)
else:
print('No clusters appear to be running.')
return True

0 comments on commit d92f542

Please sign in to comment.