[Twisted-Python] Service as a daemon

John Toohey jt at parspro.com
Thu Aug 12 13:15:40 EDT 2004


Hi all,

I have a twisted server which can be started with the following code :-

if __name__=="__main__":

     application = service.Application('feedserver', uid=1, gid=1)
     f = FeedService('feedserver')
     reactor.connectTCP('localhost',8002,f.getFactory())

     f.setServiceParent(service.IServiceCollection(application))
     f.startService()
     reactor.run()

The f.startService method makes a call to a database and using the PB 
layer, sends data to another twisted server every 5 minutes. However, 
when I try to create a .tap file and run it as a daemon with this code 
:-

def makeService(config):
     pbport = int(config["pbport"])

     application = service.Application('feedserver', uid=1, gid=1)
     f = FeedService('feedserver')
     serviceCollection = service.IServiceCollection(application)
     internet.TCPClient("localhost",pbport, 
f.getFactory()).setServiceParent(serviceCollection)
     f.startService()

     return serviceCollection

The f.startService method is not called, and the data is not sent to 
the other server. What am I missing here?

TIA

John





More information about the Twisted-Python mailing list