Permalink
Browse files

set process titles if setproctitle is installed

  • Loading branch information...
1 parent ef1b7cd commit a658d0b20b33f38695e55278ea4859e55934c68e Ask Solem committed Dec 7, 2009
Showing with 22 additions and 4 deletions.
  1. +3 −0 celery/bin/celerybeat.py
  2. +8 −1 celery/bin/celeryd.py
  3. +11 −3 celery/platform.py
View
@@ -123,6 +123,9 @@ def run_clockservice(detach=False, loglevel=conf.CELERYBEAT_LOG_LEVEL,
})
print("celerybeat has started.")
+ arg_start = "manage" in sys.argv[0] and 2 or 1
+ platform.set_process_title("celerybeat",
+ info=" ".join(sys.argv[arg_start:]))
from celery.log import setup_logger, redirect_stdouts_to_logger
if detach:
context = platform.create_daemon_context(logfile, pidfile,
View
@@ -87,7 +87,6 @@
. concurrency -> %(concurrency)s
. events -> %(events)s
. beat -> %(celerybeat)s
->>>>>>> events
""".strip()
OPTION_LIST = (
@@ -188,6 +187,7 @@ def run_worker(concurrency=conf.DAEMON_CONCURRENCY, detach=False,
})
print("Celery has started.")
+ set_process_status("Running...")
if detach:
from celery.log import setup_logger, redirect_stdouts_to_logger
context = platform.create_daemon_context(logfile, pidfile,
@@ -225,6 +225,7 @@ def run_worker():
try:
run_worker()
except:
+ set_process_status("Exiting...")
if detach:
context.close()
raise
@@ -255,6 +256,12 @@ def parse_options(arguments):
return options
+def set_process_status(info):
+ arg_start = "manage" in sys.argv[0] and 2 or 1
+ info = "%s (%s)" % (info, " ".join(sys.argv[arg_start:]))
+ platform.set_mp_process_title("celeryd", info=info)
+
+
if __name__ == "__main__":
options = parse_options(sys.argv[1:])
run_worker(**vars(options))
View
@@ -96,6 +96,14 @@ def install_signal_handler(signal_name, handler):
signal.signal(signum, handler)
-def set_process_title(title):
- if _setproctitle is not None:
- _setproctitle(title)
+def set_process_title(progname, info=None):
+ if _setproctitle:
+ proctitle = "[%s]" % progname
+ proctitle = info and "%s %s" % (proctitle, info) or proctitle
+ _setproctitle(proctitle)
+
+def set_mp_process_title(progname, info=None):
+ from multiprocessing.process import current_process
+ return set_process_title("%s.%s" % (progname, current_process().name),
+ info=info)
+

0 comments on commit a658d0b

Please sign in to comment.