
This commit removes eventlet WSGI server and starts using generic eventlet WSGI server from oslo.service library. The change where the wsgi functionality was added to oslo.service can be referenced here: If8840168f10cc3561f4f01e6d456d6b4fd1de8b5. DocImpact Depends-on: If8840168f10cc3561f4f01e6d456d6b4fd1de8b5 Implements blueprint: reusing-wsgi-from-oslo.service Closes-Bug: #1499658 Change-Id: Iea8af7b4a569fedc99e126524f18f98097c95a6d
61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
# 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.
|
|
|
|
"""Methods for working with eventlet WSGI servers."""
|
|
|
|
from __future__ import print_function
|
|
|
|
import socket
|
|
|
|
from oslo_config import cfg
|
|
from oslo_log import log as logging
|
|
from oslo_service import wsgi
|
|
from oslo_utils import netutils
|
|
|
|
|
|
socket_opts = [
|
|
cfg.BoolOpt('tcp_keepalive',
|
|
default=True,
|
|
help="Sets the value of TCP_KEEPALIVE (True/False) for each "
|
|
"server socket."),
|
|
cfg.IntOpt('tcp_keepalive_interval',
|
|
help="Sets the value of TCP_KEEPINTVL in seconds for each "
|
|
"server socket. Not supported on OS X."),
|
|
cfg.IntOpt('tcp_keepalive_count',
|
|
help="Sets the value of TCP_KEEPCNT for each "
|
|
"server socket. Not supported on OS X."),
|
|
]
|
|
|
|
|
|
CONF = cfg.CONF
|
|
CONF.register_opts(socket_opts)
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class Server(wsgi.Server):
|
|
"""Server class to manage a WSGI server, serving a WSGI application."""
|
|
|
|
def _set_socket_opts(self, _socket):
|
|
_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
|
|
# NOTE(praneshp): Call set_tcp_keepalive in oslo to set
|
|
# tcp keepalive parameters. Sockets can hang around forever
|
|
# without keepalive
|
|
netutils.set_tcp_keepalive(_socket,
|
|
self.conf.tcp_keepalive,
|
|
self.conf.tcp_keepidle,
|
|
self.conf.tcp_keepalive_count,
|
|
self.conf.tcp_keepalive_interval)
|
|
|
|
return _socket
|