Retrieve url from config file

main
zhangliyong 10 years ago
parent 229a00fee5
commit 4df076f3aa

@ -21,7 +21,7 @@ from .helpers import (read_config_file, refresh, setup_loghandlers_from_args,
show_both, show_queues, show_workers) show_both, show_queues, show_workers)
url_option = click.option('--url', '-u', envvar='URL', default='redis://localhost:6379/0', url_option = click.option('--url', '-u', envvar='RQ_REDIS_URL', default='redis://localhost:6379/0',
help='URL describing Redis connection details.') help='URL describing Redis connection details.')
@ -141,13 +141,12 @@ def worker(url, config, burst, name, worker_class, job_class, queue_class, path,
worker_ttl, verbose, quiet, sentry_dsn, pid, queues): worker_ttl, verbose, quiet, sentry_dsn, pid, queues):
"""Starts an RQ worker.""" """Starts an RQ worker."""
conn = connect(url)
if path: if path:
sys.path = path.split(':') + sys.path sys.path = path.split(':') + sys.path
settings = read_config_file(config) if config else {} settings = read_config_file(config) if config else {}
# Worker specific default arguments # Worker specific default arguments
url = url or settings.get('REDIS_URL')
queues = queues or settings.get('QUEUES', ['default']) queues = queues or settings.get('QUEUES', ['default'])
sentry_dsn = sentry_dsn or settings.get('SENTRY_DSN') sentry_dsn = sentry_dsn or settings.get('SENTRY_DSN')
@ -157,6 +156,7 @@ def worker(url, config, burst, name, worker_class, job_class, queue_class, path,
setup_loghandlers_from_args(verbose, quiet) setup_loghandlers_from_args(verbose, quiet)
conn = connect(url)
cleanup_ghosts(conn) cleanup_ghosts(conn)
worker_class = import_attribute(worker_class) worker_class = import_attribute(worker_class)
queue_class = import_attribute(queue_class) queue_class = import_attribute(queue_class)

Loading…
Cancel
Save