From 16ab25c187aa7972f85e96197cf182b009bb8465 Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Thu, 7 Sep 2017 15:44:34 -0500 Subject: [PATCH] doc: How to remote-pdb under systemd Add instructions for installing and enabling remote-pdb [1] under systemd. [1] https://pypi.python.org/pypi/remote-pdb Thanks to clarkb for pointing me to this. TIL. Change-Id: I640ac36cfbcc5b199e911c0e3f6b18705c3fbbc4 --- doc/source/systemd.rst | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/doc/source/systemd.rst b/doc/source/systemd.rst index f9971abf5a..c1d2944057 100644 --- a/doc/source/systemd.rst +++ b/doc/source/systemd.rst @@ -120,8 +120,11 @@ left/right arrow keys. See ``man 1 journalctl`` for more. -Debugging with pdb -================== +Debugging +========= + +Using pdb +--------- In order to break into a regular pdb session on a systemd-controlled service, you need to invoke the process manually - that is, take it out @@ -143,6 +146,37 @@ Invoke the command manually:: /usr/local/bin/nova-scheduler --config-file /etc/nova/nova.conf +Using remote-pdb +---------------- + +`remote-pdb`_ works while the process is under systemd control. + +Make sure you have remote-pdb installed:: + + sudo pip install remote-pdb + +Inject your breakpoint in the source, e.g.:: + + import remote_pdb; remote_pdb.set_trace() + +Restart the relevant service:: + + sudo systemctl restart devstack@n-api.service + +The remote-pdb code configures the telnet port when ``set_trace()`` is +invoked. Do whatever it takes to hit the instrumented code path, and +inspect the logs for a message displaying the listening port:: + + Sep 07 16:36:12 p8-100-neo devstack@n-api.service[772]: RemotePdb session open at 127.0.0.1:46771, waiting for connection ... + +Telnet to that port to enter the pdb session:: + + telnet 127.0.0.1 46771 + +See the `remote-pdb`_ home page for more options. + +.. _`remote-pdb`: https://pypi.python.org/pypi/remote-pdb + Known Issues ============