Optionally configure connection as path to Unix socket (tbd: actual connection)

main
Jacob Oscarson 12 years ago
parent 5a5e14cc70
commit 02288dd048

@ -36,6 +36,10 @@ def setup_default_arguments(args, settings):
else:
args.port = int(args.port)
socket = settings.get('REDIS_SOCKET', False)
if args.socket is None and socket:
args.socket = socket
if args.db is None:
args.db = settings.get('REDIS_DB', 0)

@ -27,6 +27,7 @@ def parse_args():
parser.add_argument('--quiet', '-q', action='store_true', default=False, help='Show less output')
parser.add_argument('--sentry-dsn', action='store', default=None, metavar='URL', help='Report exceptions to this Sentry DSN')
parser.add_argument('queues', nargs='*', help='The queues to listen on (default: \'default\')')
parser.add_argument('--socket', '-s', default=None, help='Use Unix socket to connect')
return parser.parse_args()

@ -3,11 +3,30 @@ if is_python_version((2, 7), (3, 2)):
from unittest import TestCase
else:
from unittest2 import TestCase # noqa
from rq.scripts import read_config_file
from rq.scripts import read_config_file, setup_redis, add_standard_arguments, setup_default_arguments
class uFaking(object):
def __init__(self, *faking):
for attr in faking:
setattr(self, attr, None)
def conf_pair(**faked_settings):
return (faked_settings,
uFaking('host', 'port', 'socket', 'db', 'queues', 'password'))
class TestScripts(TestCase):
def test_config_file(self):
settings = read_config_file("tests.dummy_settings")
self.assertIn("REDIS_HOST", settings)
self.assertEqual(settings['REDIS_HOST'], "testhost.example.com")
def test_socket_from_module(self):
settings, args = conf_pair(REDIS_SOCKET='dummy')
setup_default_arguments(args, settings)
self.assertEqual(args.socket, 'dummy')
def test_socket_from_args(self):
settings, args = conf_pair(REDIS_SOCKET='sock-read-from-config')
args.socket = 'sock-from-arg'
setup_default_arguments(args, settings)
self.assertEqual(args.socket, 'sock-from-arg')

Loading…
Cancel
Save