|
|
@ -6,27 +6,28 @@ from rq import use_connection
|
|
|
|
|
|
|
|
|
|
|
|
def add_standard_arguments(parser):
|
|
|
|
def add_standard_arguments(parser):
|
|
|
|
parser.add_argument('--config', '-c', default=None,
|
|
|
|
parser.add_argument('--config', '-c', default=None,
|
|
|
|
help='Module containing RQ settings.')
|
|
|
|
help='Module containing RQ settings.')
|
|
|
|
parser.add_argument('--url', '-u', default=None,
|
|
|
|
parser.add_argument('--url', '-u', default=None,
|
|
|
|
help='URL describing Redis connection details. '
|
|
|
|
help='URL describing Redis connection details. '
|
|
|
|
'Overrides other connection arguments if supplied.')
|
|
|
|
'Overrides other connection arguments if supplied.')
|
|
|
|
parser.add_argument('--host', '-H', default=None,
|
|
|
|
parser.add_argument('--host', '-H', default=None,
|
|
|
|
help='The Redis hostname (default: localhost)')
|
|
|
|
help='The Redis hostname (default: localhost)')
|
|
|
|
parser.add_argument('--port', '-p', default=None,
|
|
|
|
parser.add_argument('--port', '-p', default=None,
|
|
|
|
help='The Redis portnumber (default: 6379)')
|
|
|
|
help='The Redis portnumber (default: 6379)')
|
|
|
|
parser.add_argument('--db', '-d', type=int, default=None,
|
|
|
|
parser.add_argument('--db', '-d', type=int, default=None,
|
|
|
|
help='The Redis database (default: 0)')
|
|
|
|
help='The Redis database (default: 0)')
|
|
|
|
parser.add_argument('--password', '-a', default=None,
|
|
|
|
parser.add_argument('--password', '-a', default=None,
|
|
|
|
help='The Redis password (default: None)')
|
|
|
|
help='The Redis password (default: None)')
|
|
|
|
parser.add_argument('--socket', '-s', default=None,
|
|
|
|
parser.add_argument('--socket', '-s', default=None,
|
|
|
|
help='The Redis Unix socket')
|
|
|
|
help='The Redis Unix socket')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_config_file(module):
|
|
|
|
def read_config_file(module):
|
|
|
|
"""Reads all UPPERCASE variables defined in the given module file."""
|
|
|
|
"""Reads all UPPERCASE variables defined in the given module file."""
|
|
|
|
settings = importlib.import_module(module)
|
|
|
|
settings = importlib.import_module(module)
|
|
|
|
return dict([(k, v)
|
|
|
|
return dict([(k, v)
|
|
|
|
for k, v in settings.__dict__.items()
|
|
|
|
for k, v in settings.__dict__.items()
|
|
|
|
if k.upper() == k])
|
|
|
|
if k.upper() == k])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup_default_arguments(args, settings):
|
|
|
|
def setup_default_arguments(args, settings):
|
|
|
@ -35,9 +36,9 @@ def setup_default_arguments(args, settings):
|
|
|
|
args.url = settings.get('REDIS_URL')
|
|
|
|
args.url = settings.get('REDIS_URL')
|
|
|
|
|
|
|
|
|
|
|
|
if (args.host or args.port or args.socket or args.db or args.password):
|
|
|
|
if (args.host or args.port or args.socket or args.db or args.password):
|
|
|
|
warn('Host, port, db, password options for Redis will not be \
|
|
|
|
warn('Host, port, db, password options for Redis will not be '
|
|
|
|
supported in future versions of RQ. \
|
|
|
|
'supported in future versions of RQ. '
|
|
|
|
Please use `REDIS_URL` or `--url` instead.', DeprecationWarning)
|
|
|
|
'Please use `REDIS_URL` or `--url` instead.', DeprecationWarning)
|
|
|
|
|
|
|
|
|
|
|
|
if args.host is None:
|
|
|
|
if args.host is None:
|
|
|
|
args.host = settings.get('REDIS_HOST', 'localhost')
|
|
|
|
args.host = settings.get('REDIS_HOST', 'localhost')
|
|
|
@ -63,5 +64,5 @@ def setup_redis(args):
|
|
|
|
redis_conn = redis.StrictRedis.from_url(args.url)
|
|
|
|
redis_conn = redis.StrictRedis.from_url(args.url)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
redis_conn = redis.StrictRedis(host=args.host, port=args.port, db=args.db,
|
|
|
|
redis_conn = redis.StrictRedis(host=args.host, port=args.port, db=args.db,
|
|
|
|
password=args.password, unix_socket_path=args.socket)
|
|
|
|
password=args.password, unix_socket_path=args.socket)
|
|
|
|
use_connection(redis_conn)
|
|
|
|
use_connection(redis_conn)
|
|
|
|