forked from Parallels/rq-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrq_dashboard.py
More file actions
executable file
·64 lines (56 loc) · 2.64 KB
/
Copy pathrq_dashboard.py
File metadata and controls
executable file
·64 lines (56 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
import sys
import optparse
from ..app import app
from ..version import VERSION
def main():
parser = optparse.OptionParser("usage: %prog [options]")
parser.add_option('-b', '--bind', dest='bind_addr',
metavar='ADDR',
help='IP addr or hostname to bind to')
parser.add_option('-p', '--port', dest='port', type='int',
metavar='PORT',
help='port to bind to')
parser.add_option('-H', '--redis-host', dest='redis_host',
metavar='ADDR',
help='IP addr or hostname of Redis server')
parser.add_option('-P', '--redis-port', dest='redis_port', type='int',
metavar='PORT',
help='port of Redis server')
parser.add_option('--redis-password', dest='redis_password',
metavar='PASSWORD',
help='password for Redis server')
parser.add_option('-D', '--redis-database', dest='redis_database', type='int',
metavar='DB',
help='database of Redis server')
parser.add_option('-u', '--redis_url', dest='redis_url_connection',
metavar='REDIS_URL',
help='redis url connection')
parser.add_option('--interval', dest='poll_interval', type='int',
metavar='POLL_INTERVAL',
help='refresh interval')
(options, args) = parser.parse_args()
# Populate app.config from options, defaulting to app.config's original
# values, if specified, finally defaulting to something sensible.
app.config['BIND_ADDR'] = options.bind_addr or app.config.get('BIND_ADDR', '0.0.0.0')
app.config['PORT'] = options.port or app.config.get('PORT', 9181)
# Override app.config from options if specified. Otherwise leave untouched,
# so the client can use its own defauls if app.config has no values.
if options.redis_host:
app.config['REDIS_HOST'] = options.redis_host
if options.redis_port:
app.config['REDIS_PORT'] = options.redis_port
if options.redis_password:
app.config['REDIS_PASSWORD'] = options.redis_password
if options.redis_database:
app.config['REDIS_DB'] = options.redis_database
if options.poll_interval:
app.config['RQ_POLL_INTERVAL'] = options.poll_interval
app.config['REDIS_URL'] = options.redis_url_connection or None
if len(args) > 0:
parser.print_help()
sys.exit(2)
print 'RQ Dashboard, version %s' % VERSION
app.run(host=app.config['BIND_ADDR'], port=app.config['PORT'])
if __name__ == '__main__':
main()