Browse Source

Some docstrings and nicer info at startup (show version number)

Ask Solem 16 years ago
parent
commit
c48d219600
3 changed files with 14 additions and 10 deletions
  1. 11 9
      celery/bin/celeryd.py
  2. 2 1
      celery/management/commands/celerystats.py
  3. 1 0
      celery/monitoring.py

+ 11 - 9
celery/bin/celeryd.py

@@ -65,6 +65,7 @@ if django_project_dir:
     sys.path.append(django_project_dir)
 
 from django.conf import settings
+from celery import __version__
 from celery.log import emergency_error
 from celery.conf import LOG_LEVELS, DAEMON_LOG_FILE, DAEMON_LOG_LEVEL
 from celery.conf import DAEMON_CONCURRENCY, DAEMON_PID_FILE
@@ -88,11 +89,12 @@ USE_STATISTICS = getattr(settings, "CELERY_STATISTICS", False)
 settings.CELERY_STATISTICS = USE_STATISTICS
 
 STARTUP_INFO_FMT = """
-    * Celery loading with the following configuration
-        * Broker -> amqp://%(vhost)s@%(host)s:%(port)s
-        * Exchange -> %(exchange)s (%(exchange_type)s)
-        * Consumer -> Queue:%(consumer_queue)s Routing:%(consumer_rkey)s
-        * Concurrency:%(concurrency)s
+Configuration ->
+    * Broker -> amqp://%(vhost)s@%(host)s:%(port)s
+    * Exchange -> %(exchange)s (%(exchange_type)s)
+    * Consumer -> Queue:%(consumer_queue)s Routing:%(consumer_rkey)s
+    * Concurrency -> %(concurrency)s
+    * Statistics -> %(statistics)s
 """.strip()
 
 OPTION_LIST = (
@@ -173,7 +175,7 @@ def run_worker(concurrency=DAEMON_CONCURRENCY, detach=False,
         working_directory=None, chroot=None, statistics=None, **kwargs):
     """Starts the celery worker server."""
 
-    print(". Launching celery, please hold on to something...")
+    print("Celery %s is starting." % __version__)
 
     if statistics:
         settings.CELERY_STATISTICS = statistics
@@ -214,9 +216,8 @@ def run_worker(concurrency=DAEMON_CONCURRENCY, detach=False,
             "concurrency": concurrency,
             "loglevel": loglevel,
             "pidfile": pidfile,
+            "statistics": settings.CELERY_STATISTICS and "ON" or "OFF",
     })
-    print("* Reporting of statistics is %s..." % (
-        settings.CELERY_STATISTICS and "ON" or "OFF"))
 
     if detach:
         # Since without stderr any errors will be silently suppressed,
@@ -229,7 +230,6 @@ def run_worker(concurrency=DAEMON_CONCURRENCY, detach=False,
         uid = uid and int(uid) or os.geteuid()
         gid = gid and int(gid) or os.getegid()
         working_directory = working_directory or os.getcwd()
-        print("* Launching celeryd in the background...")
         context = DaemonContext(chroot_directory=chroot,
                                 working_directory=working_directory,
                                 umask=umask,
@@ -243,6 +243,8 @@ def run_worker(concurrency=DAEMON_CONCURRENCY, detach=False,
                             loglevel=loglevel,
                             logfile=logfile,
                             is_detached=detach)
+
+    print("Celery has started.")
     try:
         worker.run()
     except Exception, e:

+ 2 - 1
celery/management/commands/celerystats.py

@@ -8,7 +8,8 @@ from celery.monitoring import StatsCollector
 
 
 class Command(BaseCommand):
-    """Run the celery daemon."""
+    """Collect/flush and dump a report from the currently available
+    statistics."""
     option_list = BaseCommand.option_list
     help = "Collect/flush and dump a report from the currently available " + \
             "statistics"

+ 1 - 0
celery/monitoring.py

@@ -171,6 +171,7 @@ class StatsCollector(object):
                 handler(**stats_entry["data"])
 
     def dump_to_cache(self, cache_key_prefix=DEFAULT_CACHE_KEY_PREFIX):
+        """Store collected statistics in the cache."""
         cache.set("%s-total_tasks_processed" % cache_key_prefix,
                 self.total_tasks_processed)
         cache.set("%s-total_tasks_processed_by_type" % cache_key_prefix,