-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.py
42 lines (35 loc) · 1.07 KB
/
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
40
41
42
# coding:utf-8
__author__ = 'BLUE'
import tornado.web
import tornado.ioloop
import tornado.options
import tornado.httpserver
import redis
import config
import sys
from tornado.options import define, options
from urls_web import urls_web
from urls_admin import urls_admin
reload(sys)
sys.setdefaultencoding('utf8')
define("port", default=8080, type=int, help="run server on the given port")
class Application(tornado.web.Application):
def __init__(self, *args, **kwargs):
super(Application, self).__init__(*args, **kwargs)
self.redis = redis.StrictRedis(**config.redis_options)
def main():
# 日志位置
# options.log_file_prefix = config.log_path
# 日志等级
# options.logging = config.log_level
options.parse_command_line()
urls_web.extend(urls_admin)
app = Application(
urls_web,
**config.settings
)
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.current().start()
if __name__ == '__main__':
main()