forked from binarymatt/pyres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyres_worker
More file actions
executable file
·37 lines (26 loc) · 1.32 KB
/
pyres_worker
File metadata and controls
executable file
·37 lines (26 loc) · 1.32 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
#!/usr/bin/env python
import logging
from optparse import OptionParser
from pyres.worker import Worker
def main():
usage = "usage: %prog [options] arg1"
parser = OptionParser(usage=usage)
#parser.add_option("-q", dest="queue_list")
parser.add_option("--host", dest="host", default="localhost")
parser.add_option("--port",dest="port",type="int", default=6379)
parser.add_option("-i", '--interval', dest='interval', default=None, help='the default time interval to sleep between runs')
parser.add_option('-l', '--log-level', dest='log_level', default='info', help='log level. Valid values are "debug", "info", "warning", "error", "critical", in decreasing order of verbosity. Defaults to "info" if parameter not specified.')
(options,args) = parser.parse_args()
if len(args) != 1:
parser.print_help()
parser.error("Argument must be a comma seperated list of queues")
log_level = getattr(logging, options.log_level.upper(), 'INFO')
logging.basicConfig(level=log_level, format="%(asctime)s: %(levelname)s: %(message)s")
interval = options.interval
if interval is not None:
interval = float(interval)
queues = args[0].split(',')
server = '%s:%s' % (options.host,options.port)
Worker.run(queues, server, interval)
if __name__ == "__main__":
main()