Adding a means for a glance worker to connect back to a pydevd debugger.
That patch allows a developer to remotely run a pydev debugger and a glance worker process connect back to it. Two configuration options have been added: pydev_worker_debug_host <host>. Default is None pydev_worker_debug_port <port>. Default is 5678 The behavior is enabled if pydev_worker_debug_host is not None. If a pydev connection fails to be esstablished an exception is raised. This patch will allow remote debugging as well as more seemless debugging environments with IDEs like pycharm. Change-Id: I7d3f60e373632b256f0e914f18204ce223a3486e
This commit is contained in:
parent
0e9111ca59
commit
01c6bcd9e4
@ -58,6 +58,12 @@ common_opts = [
|
||||
help=_("Deploy the v1 OpenStack Images API. ")),
|
||||
cfg.BoolOpt('enable_v2_api', default=True,
|
||||
help=_("Deploy the v2 OpenStack Images API. ")),
|
||||
cfg.StrOpt('pydev_worker_debug_host', default=None,
|
||||
help=_('The hostname/IP of the pydev process listening for '
|
||||
'debug connections')),
|
||||
cfg.IntOpt('pydev_worker_debug_port', default=5678,
|
||||
help=_('The port on which a pydev process is listening for '
|
||||
'connections.')),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -36,6 +36,7 @@ import sys
|
||||
from webob import exc
|
||||
|
||||
from glance.common import exception
|
||||
from glance.openstack.common import cfg
|
||||
import glance.openstack.common.log as logging
|
||||
|
||||
|
||||
@ -410,3 +411,23 @@ def mutating(func):
|
||||
content_type="text/plain")
|
||||
return func(self, req, *args, **kwargs)
|
||||
return wrapped
|
||||
|
||||
|
||||
def setup_remote_pydev_debug(host, port):
|
||||
|
||||
error_msg = ('Error setting up the debug environment. Verify that the'
|
||||
' option pydev_worker_debug_port is pointing to a valid '
|
||||
'hostname or IP on which a pydev server is listening on'
|
||||
' the port indicated by pydev_worker_debug_port.')
|
||||
|
||||
try:
|
||||
from pydev import pydevd
|
||||
|
||||
pydevd.settrace(host,
|
||||
port=port,
|
||||
stdoutToServer=True,
|
||||
stderrToServer=True)
|
||||
return True
|
||||
except:
|
||||
LOG.exception(error_msg)
|
||||
raise
|
||||
|
@ -40,6 +40,7 @@ import webob.dec
|
||||
import webob.exc
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import cfg
|
||||
import glance.openstack.common.log as os_logging
|
||||
|
||||
@ -266,6 +267,10 @@ class Server(object):
|
||||
|
||||
def run_server(self):
|
||||
"""Run a WSGI server."""
|
||||
if cfg.CONF.pydev_worker_debug_host:
|
||||
utils.setup_remote_pydev_debug(cfg.CONF.pydev_worker_debug_host,
|
||||
cfg.CONF.pydev_worker_debug_port)
|
||||
|
||||
eventlet.wsgi.HttpProtocol.default_request_version = "HTTP/1.0"
|
||||
try:
|
||||
eventlet.hubs.use_hub('poll')
|
||||
|
Loading…
Reference in New Issue
Block a user