Browse code

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

Eric Fried authored on 2017/09/08 05:44:34
Showing 1 changed files
... ...
@@ -120,8 +120,11 @@ left/right arrow keys.
120 120
 
121 121
 See ``man 1 journalctl`` for more.
122 122
 
123
-Debugging with pdb
124
-==================
123
+Debugging
124
+=========
125
+
126
+Using pdb
127
+---------
125 128
 
126 129
 In order to break into a regular pdb session on a systemd-controlled
127 130
 service, you need to invoke the process manually - that is, take it out
... ...
@@ -143,6 +146,37 @@ Invoke the command manually::
143 143
 
144 144
   /usr/local/bin/nova-scheduler --config-file /etc/nova/nova.conf
145 145
 
146
+Using remote-pdb
147
+----------------
148
+
149
+`remote-pdb`_ works while the process is under systemd control.
150
+
151
+Make sure you have remote-pdb installed::
152
+
153
+  sudo pip install remote-pdb
154
+
155
+Inject your breakpoint in the source, e.g.::
156
+
157
+  import remote_pdb; remote_pdb.set_trace()
158
+
159
+Restart the relevant service::
160
+
161
+  sudo systemctl restart devstack@n-api.service
162
+
163
+The remote-pdb code configures the telnet port when ``set_trace()`` is
164
+invoked.  Do whatever it takes to hit the instrumented code path, and
165
+inspect the logs for a message displaying the listening port::
166
+
167
+  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 ...
168
+
169
+Telnet to that port to enter the pdb session::
170
+
171
+  telnet 127.0.0.1 46771
172
+
173
+See the `remote-pdb`_ home page for more options.
174
+
175
+.. _`remote-pdb`: https://pypi.python.org/pypi/remote-pdb
176
+
146 177
 Known Issues
147 178
 ============
148 179