<span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size: 11pt; "><div>I’ve got an app written that runs as a service using twisted.application.service that I need to tunnel through SSH. Right now, I use a script that makes use of Paramiko (and runs separate from my app) to set up a tunnel. That more or less works, but I’ve had some problems with the tunnel just going away and would like to integrate the tunneling into the app, using conch. I’ve found an example of tunneling via conch, at <a href="http://twistedmatrix.com/pipermail/twisted-python/2009-February/019196.html">http://twistedmatrix.com/pipermail/twisted-python/2009-February/019196.html</a>, that I think I can use as a base to add the code to my app.</div>
<br>Right now my app is basically:<br><br>class DataPuller(service.Service):<br>    ...Code for my app...<br>    ... The app pulls data from a database and I can only connect to the server via SSH...<br><br>application = service.Application(‘Data_puller’)<br>
dpService = DataPuller()<br>dpService.setServiceParent(application)<br><br>My main problems are that I’m not sure whether or not the example linked to above is a good one for tunneling with conch and, if it is, how do I merge the example tunneling code with my app code. From the example, where the code is:<br>
<br> class Connection(connection.SSHConnection):<br>        .<br>        .<br>        .<br>        def serviceStarted(self):<br><br>Do I instantiate my DataPuller class there, in serviceStarted (and not subclass from service.Service)? If so, how do I wrap the tunneling code so that I can make it a service? If not, do I need put the tunneling code inside my DataPuller class? What would that look like?<br>
<br>Any help will be greatly appreciated.<br><br>Sean M Hollingsworth</span></font> </span>