diff --git a/bin/rqinfo b/bin/rqinfo index 73649dd8..b1c7813b 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()