Support api_workers option when using pecan
Use the same wsgi server as the homegrown method dispatch so we get support for api_workers and plugin workers when using pecan. Partially-Implements: wsgi-pecan-switch Change-Id: I9fb942651d9b52b48e8cd80b0a6ab77ec37ea1e8
This commit is contained in:
parent
3d84277897
commit
f37079592b
|
@ -22,9 +22,13 @@ LOG = log.getLogger(__name__)
|
|||
|
||||
|
||||
def eventlet_wsgi_server():
|
||||
neutron_api = service.serve_wsgi(service.NeutronApiService)
|
||||
start_api_and_rpc_workers(neutron_api)
|
||||
|
||||
|
||||
def start_api_and_rpc_workers(neutron_api):
|
||||
pool = eventlet.GreenPool()
|
||||
|
||||
neutron_api = service.serve_wsgi(service.NeutronApiService)
|
||||
api_thread = pool.spawn(neutron_api.wait)
|
||||
|
||||
try:
|
||||
|
|
|
@ -11,48 +11,18 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging as std_logging
|
||||
from wsgiref import simple_server
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from six.moves import socketserver
|
||||
|
||||
from neutron._i18n import _LI, _LW
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron._i18n import _LI
|
||||
from neutron.pecan_wsgi import app as pecan_app
|
||||
from neutron.server import wsgi_eventlet
|
||||
from neutron import service
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class ThreadedSimpleServer(socketserver.ThreadingMixIn,
|
||||
simple_server.WSGIServer):
|
||||
pass
|
||||
|
||||
|
||||
def pecan_wsgi_server():
|
||||
LOG.info(_LI("Pecan WSGI server starting..."))
|
||||
application = pecan_app.setup_app()
|
||||
# this launches RPC workers in separate processes
|
||||
service.serve_rpc()
|
||||
# No AMQP connection should be created within this process
|
||||
n_rpc.RPC_DISABLED = True
|
||||
|
||||
host = cfg.CONF.bind_host
|
||||
port = cfg.CONF.bind_port
|
||||
|
||||
wsgi = simple_server.make_server(
|
||||
host,
|
||||
port,
|
||||
application,
|
||||
server_class=ThreadedSimpleServer
|
||||
)
|
||||
# Log option values
|
||||
cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
|
||||
LOG.warning(
|
||||
_LW("Development Server Serving on http://%(host)s:%(port)s"),
|
||||
{'host': host, 'port': port}
|
||||
)
|
||||
|
||||
wsgi.serve_forever()
|
||||
neutron_api = service.run_wsgi_app(application)
|
||||
wsgi_eventlet.start_api_and_rpc_workers(neutron_api)
|
||||
|
|
|
@ -232,6 +232,10 @@ def _run_wsgi(app_name):
|
|||
if not app:
|
||||
LOG.error(_LE('No known API applications configured.'))
|
||||
return
|
||||
return run_wsgi_app(app)
|
||||
|
||||
|
||||
def run_wsgi_app(app):
|
||||
server = wsgi.Server("Neutron")
|
||||
server.start(app, cfg.CONF.bind_port, cfg.CONF.bind_host,
|
||||
workers=_get_api_workers())
|
||||
|
|
Loading…
Reference in New Issue