forked from liuhong1happy/DockerConsoleApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·85 lines (79 loc) · 3.24 KB
/
manage.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tornado.ioloop
import tornado.web
from tornado.options import define, options
from tornado import gen
import tornado.httpserver
import os.path
import settings
from util.db import init_db
from util.discover import init_etcd
from util.dockerclient import init_docker
from util.rabbitmq import init_amqp
define("port", default=settings.TORNADO_PORT, help="run on the given port", type=int)
define("ioloop",default=None,help="global ioloop instance",type=object)
class Application(tornado.web.Application):
def __init__(self):
self.init_service()
from views.home import HomeHandler
from views.service import ServicesHandler,ServiceInfoHandler,ServiceBuildHandler
from views.login import LoginHandler,SigninHandler,SignupHandler,ForgetHandler
from views.oauth import GitLabOAuthHandler,GitLabTokenHandler,GitLabRefreshHanlder
from views.application import ApplicationsHandler,ApplicationInfoHandler,ApplicationRunHandler,ApplicationAccessHandler
from views.registry import RegistryHandler
handlers = [
(r"/", HomeHandler),
(r"/login",LoginHandler),
(r"/api/user/signup",SignupHandler),
(r"/api/user/signin",SigninHandler),
(r"/api/user/forget",ForgetHandler),
(r"/api/services",ServicesHandler),
(r"/api/service/info",ServiceInfoHandler),
(r"/api/service/build",ServiceBuildHandler),
(r"/api/applications",ApplicationsHandler),
(r"/api/application/info",ApplicationInfoHandler),
(r"/api/application/run",ApplicationRunHandler),
(r"/api/application/access",ApplicationAccessHandler),
(r"/api/gitlab/oauth",GitLabOAuthHandler),
(r"/api/gitlab/token",GitLabTokenHandler),
(r"/api/gitlab/refresh",GitLabRefreshHanlder),
(r"/api/registry",RegistryHandler)
]
_settings = dict(
blog_title=u"Docker中文翻译社区",
template_path=os.path.join(os.path.dirname(__file__), "dist"),
static_path=os.path.join(os.path.dirname(__file__), "dist"),
xsrf_cookies=False,
cookie_secret="AAAAB3NzaC1yc2EAAAADAQABAAABAQCww",
login_url="/login",
debug=True,
pycket = {
'engine': 'redis',
'storage': {
'host': settings.REDIS_HOST,
'port': settings.REDIS_PORT,
'db_sessions': 10,
'db_notifications': 11,
'max_connections': 2 ** 31,
},
'cookies': {
'expires_days': 120,
},
},
)
tornado.web.Application.__init__(self, handlers, **_settings)
def init_service(self):
init_db()
init_etcd()
init_docker()
init_amqp()
def main():
tornado.options.parse_command_line()
http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(options.port)
ioloop_instance = tornado.ioloop.IOLoop.instance()
options.ioloop = ioloop_instance
ioloop_instance.start()
if __name__ == "__main__":
main()