mirror of https://github.com/rq/rq.git
Add --host and --port options to specify what Redis to use.
This commit is contained in:
parent
56d05c3509
commit
1dba21f176
14
bin/rqinfo
14
bin/rqinfo
|
@ -3,6 +3,8 @@
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
|
import redis
|
||||||
|
from redis.exceptions import ConnectionError
|
||||||
from rq import use_redis, Queue, Worker
|
from rq import use_redis, Queue, Worker
|
||||||
from rq.utils import gettermsize, make_colorizer
|
from rq.utils import gettermsize, make_colorizer
|
||||||
|
|
||||||
|
@ -113,6 +115,8 @@ def show_workers(args):
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description='awesome')
|
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 = 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)')
|
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():
|
def main():
|
||||||
args = parse_args()
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue