Skip to content

Commit 7b7dc4a

Browse files
committed
Merge pull request binarymatt#101 from irae/patch-1
Added option to connect to redis servers requiring authentication.
2 parents 99de661 + b6260e8 commit 7b7dc4a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pyres/scripts.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def pyres_web():
7474
parser.add_option("--dsn",
7575
dest="dsn",
7676
help="Redis server to display")
77+
parser.add_option("--auth",
78+
dest="auth",
79+
help="Redis user:pass")
7780
parser.add_option("--server",
7881
dest="server",
7982
help="Server for itty to run under.",
@@ -82,7 +85,14 @@ def pyres_web():
8285

8386
if options.dsn:
8487
from pyres import ResQ
85-
resweb_server.HOST = ResQ(options.dsn)
88+
if options.auth is not None:
89+
from redis import Redis
90+
rhost, rport = options.dsn.split(':')
91+
ruser, rpass = options.auth.split(':')
92+
redis = Redis(host=rhost, port=int(rport), db=ruser, password=rpass)
93+
resweb_server.HOST = ResQ(redis)
94+
else:
95+
resweb_server.HOST = ResQ(options.dsn)
8696
run_itty(host=options.host, port=options.port, server=options.server)
8797

8898

0 commit comments

Comments
 (0)