mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 01:08:12 +08:00
Option to print IDs (PIDs) of running clusters added to qinfo. This provides an easy way for scripts and process managers to fetch the PID(s) of running clusters.
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from optparse import make_option
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from django_q import VERSION
|
|
from django_q.conf import Conf
|
|
from django_q.monitor import info, get_ids
|
|
|
|
|
|
class Command(BaseCommand):
|
|
# Translators: help text for qinfo management command
|
|
help = _('General information over all clusters.')
|
|
|
|
option_list = BaseCommand.option_list + (
|
|
make_option('--config',
|
|
action='store_true',
|
|
dest='config',
|
|
default=False,
|
|
help='Print current configuration.'),
|
|
make_option('--ids',
|
|
action='store_true',
|
|
dest='ids',
|
|
default=False,
|
|
help='Print cluster task IDs (PIDs).'),
|
|
)
|
|
|
|
def handle(self, *args, **options):
|
|
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)))
|
|
for setting in settings:
|
|
value = getattr(Conf, setting)
|
|
if value is not None:
|
|
self.stdout.write('{}: {}'.format(setting, value))
|
|
else:
|
|
info()
|