Merge "Adding a means for a glance worker to connect back to a pydevd debugger."

This commit is contained in:
Jenkins 2013-01-04 01:33:34 +00:00 committed by Gerrit Code Review
commit 284f12cf16
3 changed files with 32 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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')