3 # Copyright 2010 United States Government as represented by the
4 # Administrator of the National Aeronautics and Space Administration.
5 # Copyright 2011 OpenStack Foundation
8 # Licensed under the Apache License, Version 2.0 (the "License"); you may
9 # not use this file except in compliance with the License. You may obtain
10 # a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 # License for the specific language governing permissions and limitations
29 from oslo.service import systemd
30 from oslo.config import cfg
31 from oslo.log import log as logging
32 import osprofiler.notifier
35 from escalator.common import config
36 from escalator.common import wsgi
37 from escalator import notifier
40 # Monkey patch socket, time, select, threads
41 eventlet.patcher.monkey_patch(all=False, socket=True, time=True,
42 select=True, thread=True, os=True)
44 # If ../escalator/__init__.py exists, add ../ to Python search path, so that
45 # it will override what happens to be installed in /usr/(local/)lib/python...
46 possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
49 if os.path.exists(os.path.join(possible_topdir, 'escalator', '__init__.py')):
50 sys.path.insert(0, possible_topdir)
54 CONF.import_group("profiler", "escalator.common.wsgi")
55 logging.register_options(CONF)
65 wsgi.set_eventlet_hub()
66 logging.setup(CONF, 'escalator')
68 if cfg.CONF.profiler.enabled:
69 _notifier = osprofiler.notifier.create("Messaging",
70 notifier.messaging, {},
71 notifier.get_transport(),
74 osprofiler.notifier.set(_notifier)
76 osprofiler.web.disable()
78 server = wsgi.Server()
79 server.start(config.load_paste_app('escalator-api'), default_port=9393)
82 except Exception as e:
86 if __name__ == '__main__':