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
|
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
import greenlet
import logging
import os
import sys
# If ../keystone/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(possible_topdir,
'keystone',
'__init__.py')):
sys.path.insert(0, possible_topdir)
from paste import deploy
from keystone import config
from keystone.common import wsgi
CONF = config.CONF
def create_server(conf, name, host, port):
app = deploy.loadapp('config:%s' % conf, name=name)
return wsgi.Server(app, host=host, port=port)
def serve(*servers):
for server in servers:
logging.debug("starting server %s on port %s",
server.application,
server.port)
server.start()
for server in servers:
try:
server.wait()
except greenlet.GreenletExit:
pass
if __name__ == '__main__':
dev_conf = os.path.join(possible_topdir,
'etc',
'keystone.conf')
config_files = None
if os.path.exists(dev_conf):
config_files = [dev_conf]
CONF(config_files=config_files, args=sys.argv)
config.setup_logging(CONF)
# Log the options used when starting if we're in debug mode...
if CONF.debug:
CONF.log_opt_values(logging.getLogger(CONF.prog), logging.DEBUG)
options = deploy.appconfig('config:%s' % CONF.config_file[0])
servers = []
servers.append(create_server(CONF.config_file[0],
'admin',
options['bind_host'],
int(options['admin_port'])))
servers.append(create_server(CONF.config_file[0],
'main',
options['bind_host'],
int(options['public_port'])))
serve(*servers)
|