소스 검색

Add celerymon management command to celery (shows installation instructions if celerymon is not installed)

Ask Solem 15 년 전
부모
커밋
ef1b7cd215
1개의 변경된 파일37개의 추가작업 그리고 0개의 파일을 삭제
  1. 37 0
      celery/management/commands/celerymon.py

+ 37 - 0
celery/management/commands/celerymon.py

@@ -0,0 +1,37 @@
+"""
+
+Start the celery clock service from the Django management command.
+
+"""
+import sys
+from django.core.management.base import BaseCommand
+
+#try:
+from celerymonitor.bin.celerymond import run_monitor, OPTION_LIST
+#except ImportError:
+#    OPTION_LIST = ()
+#    run_monitor = None
+
+MISSING = """
+You don't have celerymon installed, please install it by running the following
+command:
+
+    $ easy_install celerymon
+
+or if you're using pip (like you should be):
+
+    $ pip install celerymon
+"""
+
+
+class Command(BaseCommand):
+    """Run the celery monitor."""
+    option_list = BaseCommand.option_list + OPTION_LIST
+    help = 'Run the celery monitor'
+
+    def handle(self, *args, **options):
+        """Handle the management command."""
+        if run_monitor is None:
+            sys.stderr.write(MISSING)
+        else:
+            run_monitor(**options)