-
Notifications
You must be signed in to change notification settings - Fork 5
/
redqueue_server.py
executable file
·39 lines (34 loc) · 1.34 KB
/
redqueue_server.py
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
#!/usr/bin/python
####################################################################
#
# All of the deliverable code in REDQUEUE has been dedicated to the
# PUBLIC DOMAIN by the authors.
#
# Author: Zeng Ke superisaac.ke at gmail dot com
#
####################################################################
import re, os, sys
import logging
from tornado import ioloop
import tornado.options
from tornado.options import define, options
from redqueue.server import Server
from redqueue import task
define('host', default="0.0.0.0", help="The binded ip host")
define('port', default=11211, type=int, help='The port to be listened')
define('jdir', default='journal', help='The directory to put journals')
define('reliable', default='yes', help='Store data to log files, options: (no, yes, sync)')
define('logfile', default='', help='Place where logging rows(info, debug, ...) are put.')
def main():
tornado.options.parse_command_line()
if options.logfile:
logging.basicConfig(filename=options.logfile, level=logging.DEBUG)
if not os.path.isdir(options.jdir):
logging.error('Log directory %s does not exist.' % options.jdir)
sys.exit(1)
server = Server(options.jdir, options.reliable)
server.start(options.host, options.port)
task.run_all(server)
ioloop.IOLoop.instance().start()
if __name__ == '__main__':
main()