-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.py
39 lines (28 loc) · 1.12 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
import config
import logging
import tornado.log
import tornado.web
import tornado.ioloop
import tornado.httpserver
from utils.urls import urls
from utils.logger import logger
from api.redis_client import redis_client, eth_lstm_model
from api.r_task_client import r_task_client
from tornado.options import options, parse_command_line
tornado.options.define("port", default=config.port, type=int, help="run server on the given port")
def main():
formatter = tornado.log.LogFormatter(fmt=config.log_format, datefmt=config.log_date_format, color=True)
parse_command_line()
[i.setFormatter(formatter) for i in logging.getLogger().handlers]
app = tornado.web.Application(urls, **config.settings)
logger.info(f"tornado httpserver runing, interface address is http://127.0.0.1:{options.port}/")
http_server = tornado.httpserver.HTTPServer(app)
# http_server.listen(options.port)
http_server.bind(options.port)
http_server.start(config.max_workers)
tornado.ioloop.IOLoop.current().start()
if __name__ == "__main__":
r_task_client.start()
redis_client.start()
eth_lstm_model.start()
main()