When someone is remotely hitting a Django server (say, not with a browser, but with a robot or other automated tool), what is the “nice” way for me to trace what the server is doing, and attempt to debug any problems?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What you should do
Debugging should not be done on a production server, so you should use a development server, where you can basically use
manage.py runserver+import pdb; pdb.set_trace().Why couldn’t you do it
Say your dev server is running on a platform like heroku, you might not be able to control how your script is started. From there, using remote-debugging is possible, and here’s how you could do it:
What you could do
If you want to be able to step-in code execution and debug remotely (which is totally innapropriate for a production setup), you could use
rpdb. I insist on the fact that you shouldn’t be doing this unless you know what you’re doing (and provided you’re not doing it on a production server!)Basically, what
rpdbdoes is that when you callrpdb.set_trace(),pdbis started and itsstdinandstdoutare redirected towards port 4444 (but you can change that of course). You’d then telnet (or netcat, for that matter) to that port and do your debugging thing from there.Closing words
Really, you shouldn’t be doing this.