From 051104b0ffc3a3b25438679be04a10bc5285718b Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 19 Oct 2018 21:46:04 -0700 Subject: [PATCH] support workder name override from config file (#947) * support workder name override from config file * update docs for NAME config * Update workers.md --- docs/docs/workers.md | 3 +++ rq/cli/cli.py | 1 + 2 files changed, 4 insertions(+) diff --git a/docs/docs/workers.md b/docs/docs/workers.md index 45bd98f..414d89c 100644 --- a/docs/docs/workers.md +++ b/docs/docs/workers.md @@ -225,6 +225,9 @@ QUEUES = ['high', 'normal', 'low'] # to configure RQ for it in a single step # The 'sync+' prefix is required for raven: https://github.com/nvie/rq/issues/350#issuecomment-43592410 SENTRY_DSN = 'sync+http://public:secret@example.com/1' + +# If you want custom worker name +# NAME = 'worker-1024' {% endhighlight %} The example above shows all the options that are currently supported. diff --git a/rq/cli/cli.py b/rq/cli/cli.py index 172fac1..81ef810 100755 --- a/rq/cli/cli.py +++ b/rq/cli/cli.py @@ -196,6 +196,7 @@ def worker(cli_config, burst, logging_level, name, results_ttl, # Worker specific default arguments queues = queues or settings.get('QUEUES', ['default']) sentry_dsn = sentry_dsn or settings.get('SENTRY_DSN') + name = name or settings.get('NAME') if pid: with open(os.path.expanduser(pid), "w") as fp: