cf786220f9
Fixed H102 errors Hacking 0.6 already pins down pep8, pyflakes and flake8 so they can be removed from test-requirements as they are indirect dependencies. Co-author: Joe Gordon <joe.gordon0@gmail.com> Change-Id: If7e79c70fe44d7e42a14cd6c710fd9986f995446
133 lines
4.3 KiB
Python
Executable File
133 lines
4.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright 2013 OpenStack Foundation
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import logging
|
|
import os
|
|
import signal
|
|
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(__file__),
|
|
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
|
|
import pbr.version
|
|
|
|
from keystone.openstack.common import gettextutils
|
|
|
|
# NOTE(blk-u):
|
|
# gettextutils.install() must run to set _ before importing any modules that
|
|
# contain static translated strings.
|
|
#
|
|
# Configure gettextutils for deferred translation of messages
|
|
# so that error messages in responses can be translated according to the
|
|
# Accept-Language in the request rather than the Keystone server locale.
|
|
gettextutils.install('keystone', lazy=True)
|
|
|
|
from keystone.common import environment
|
|
from keystone.common import utils
|
|
from keystone import config
|
|
from keystone.openstack.common import importutils
|
|
|
|
|
|
CONF = config.CONF
|
|
|
|
|
|
def create_server(conf, name, host, port):
|
|
app = deploy.loadapp('config:%s' % conf, name=name)
|
|
server = environment.Server(app, host=host, port=port)
|
|
if CONF.ssl.enable:
|
|
server.set_ssl(CONF.ssl.certfile, CONF.ssl.keyfile,
|
|
CONF.ssl.ca_certs, CONF.ssl.cert_required)
|
|
return server
|
|
|
|
|
|
def sigint_handler(signal, frame):
|
|
"""Exits at SIGINT signal."""
|
|
logging.debug('SIGINT received, stopping servers.')
|
|
sys.exit(0)
|
|
|
|
|
|
def serve(*servers):
|
|
signal.signal(signal.SIGINT, sigint_handler)
|
|
|
|
for server in servers:
|
|
server.start()
|
|
|
|
# notify calling process we are ready to serve
|
|
if CONF.onready:
|
|
try:
|
|
notifier = importutils.import_module(CONF.onready)
|
|
notifier.notify()
|
|
except ImportError:
|
|
try:
|
|
utils.check_output(CONF.onready.split())
|
|
except Exception:
|
|
logging.exception('Failed to execute onready command')
|
|
|
|
for server in servers:
|
|
server.wait()
|
|
|
|
|
|
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(project='keystone',
|
|
version=pbr.version.VersionInfo('keystone').version_string(),
|
|
default_config_files=config_files)
|
|
|
|
config.setup_logging(CONF, product_name='keystone')
|
|
|
|
# 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)
|
|
|
|
paste_config = config.find_paste_config()
|
|
|
|
monkeypatch_thread = not CONF.standard_threads
|
|
pydev_debug_url = utils.setup_remote_pydev_debug()
|
|
if pydev_debug_url:
|
|
# in order to work around errors caused by monkey patching we have to
|
|
# set the thread to False. An explanation is here:
|
|
# http://lists.openstack.org/pipermail/openstack-dev/2012-August/
|
|
# 000794.html
|
|
monkeypatch_thread = False
|
|
environment.use_eventlet(monkeypatch_thread)
|
|
|
|
servers = []
|
|
servers.append(create_server(paste_config,
|
|
'admin',
|
|
CONF.bind_host,
|
|
int(CONF.admin_port)))
|
|
servers.append(create_server(paste_config,
|
|
'main',
|
|
CONF.bind_host,
|
|
int(CONF.public_port)))
|
|
serve(*servers)
|