Hi,
I am experimenting with the attachable Python debugger of VSCode. In principle you write something like this at the beginning of your code:
import debugpy
debugpy.listen(8260)
debugpy.wait_for_client()
debugpy.breakpoint()
Then the debugger initializes, listens and waits on port 8260 until VSCode has connected to it. Then it stops at the breakpoint and you can debug your program through a SSH tunnel remotely.
Now I want to make it work with Plone. Say I have installed a zope2instance named client1
. Where do I put that code now? I never dug so deep down to the starting process of an instance. Depending on which command I use (fg, console, debug, start, run) different things happen, sometimes processes were forked, sometimes the current process is replaced and sometimes a subprocess is going to be started. And codes and scripts were compiled at runtime and then executed.
I really wish there was a command like client1 debugpy 8260
which starts client1
in console mode and runs the few lines I mentioned before. That would be a nice extension for the zope2instance
recipe.
However since there is no such command, how could I simulate that behaviour? Can I create a script which initializes debugpy and starts Plone normally, and then I run this script with client1 run <script>
? If yes, how has this script to look like? I know how to write scripts which runs catalog updates or makes a quickinstall on every available Plone site but how can I start the service like fg
or console
does it?
Thank you!