From 1dba21f1765ba31c55192a26cf0b9680b148890a Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Mon, 28 Nov 2011 13:58:13 +0100 Subject: [PATCH] Add --host and --port options to specify what Redis to use. --- bin/rqinfo | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/rqinfo b/bin/rqinfo index 73649dd..b1c7813 100755 --- a/bin/rqinfo +++ b/bin/rqinfo @@ -3,6 +3,8 @@ import os import time import argparse +import redis +from redis.exceptions import ConnectionError from rq import use_redis, Queue, Worker from rq.utils import gettermsize, make_colorizer @@ -113,6 +115,8 @@ def show_workers(args): def parse_args(): parser = argparse.ArgumentParser(description='awesome') + parser.add_argument('--host', '-H', default='localhost', help='The Redis hostname (default: localhost)') + parser.add_argument('--port', '-p', type=int, default=6379, help='The Redis portnumber (default: 6379)') parent_parser = argparse.ArgumentParser(add_help=False) parent_parser.add_argument('--interval', '-i', metavar='N', type=float, default=0, help='Updates stats every N seconds (default: don\'t poll)') @@ -133,8 +137,14 @@ def parse_args(): def main(): args = parse_args() - use_redis() - args.func(args) + + # Setup connection to Redis + redis_conn = redis.Redis(host=args.host, port=args.port) + use_redis(redis_conn) + try: + args.func(args) + except ConnectionError as e: + print(e) if __name__ == '__main__': main()