mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-25 18:38:11 +08:00
26 lines
707 B
Python
26 lines
707 B
Python
from optparse import make_option
|
|
|
|
from django.core.management.base import BaseCommand
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from django_q.cluster import Cluster
|
|
|
|
|
|
class Command(BaseCommand):
|
|
# Translators: help text for qcluster management command
|
|
help = _("Starts a Django Q Cluster.")
|
|
|
|
option_list = BaseCommand.option_list + (
|
|
make_option('--run-once',
|
|
action='store_true',
|
|
dest='run_once',
|
|
default=False,
|
|
help='Run once and then stop.'),
|
|
)
|
|
|
|
def handle(self, *args, **options):
|
|
q = Cluster()
|
|
q.start()
|
|
if options.get('run_once', False):
|
|
q.stop()
|