mirror of https://github.com/rq/rq.git
Add a standard --url argument to all scripts.
redis-py now supports URL-based connection configuration. When --url is specified, we use it to construct the Redis object. Otherwise, we use the existing argument-based construction method. `Redis.from_url()` is new in redis-py 2.6.2, so that prerequisite has been adjusted accordingly.
This commit is contained in:
parent
b97a9df69c
commit
eb00f69ced
|
@ -5,6 +5,8 @@ from rq import use_connection
|
|||
def add_standard_arguments(parser):
|
||||
parser.add_argument('--config', '-c', default=None,
|
||||
help='Module containing RQ settings.')
|
||||
parser.add_argument('--url', '-u', default=None,
|
||||
help='URL describing Redis connection details')
|
||||
parser.add_argument('--host', '-H', default=None,
|
||||
help='The Redis hostname (default: localhost)')
|
||||
parser.add_argument('--port', '-p', default=None,
|
||||
|
@ -44,6 +46,9 @@ def setup_default_arguments(args, settings):
|
|||
|
||||
|
||||
def setup_redis(args):
|
||||
redis_conn = redis.Redis(host=args.host, port=args.port, db=args.db,
|
||||
password=args.password)
|
||||
if args.url is not None:
|
||||
redis_conn = redis.Redis.from_url(args.url, db=args.db)
|
||||
else:
|
||||
redis_conn = redis.Redis(host=args.host, port=args.port, db=args.db,
|
||||
password=args.password)
|
||||
use_connection(redis_conn)
|
||||
|
|
Loading…
Reference in New Issue