-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (27 loc) · 923 Bytes
/
app.py
File metadata and controls
29 lines (27 loc) · 923 Bytes
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
import os
from tornado.ioloop import IOLoop
from tornado.options import parse_config_file, parse_command_line, options
from cmdb import make_app
from cmdb.schema import SchemaHandler
from cmdb.entity import EntityHandler
from cmdb.entity import EntitySearchHandler
routes = [
(r'/schema', SchemaHandler),
(r'/schema/(.*)', SchemaHandler),
(r'/entity/(\w+)', EntityHandler),
(r'/entity/(\w+)/(.*)', EntityHandler),
(r'/_search', EntitySearchHandler)
]
if __name__ == '__main__':
if os.path.exists('/etc/cmdb.conf'):
parse_config_file('/etc/cmdb.conf')
if os.path.exists('./application.conf'):
parse_config_file('./application.conf')
parse_command_line()
app = make_app(routes, debug=True)
app.listen(options.port, address=options.bind)
try:
app.zk.start()
IOLoop().current().start()
except KeyboardInterrupt:
IOLoop().current().stop()