X-Git-Url: https://git.mxchange.org/?p=quix0rs-apt-p2p.git;a=blobdiff_plain;f=apt-p2p.py;h=911dfce162bfd55d0cbc19097a77ee00a285a77a;hp=adbc7bdd72e679c67d3140a756760a71b102217c;hb=63dffea17bbfc90dcfb66ec22f48800e71888bc9;hpb=19dab12a49b05e17b3fc9e6fc246c31f157b4f48 diff --git a/apt-p2p.py b/apt-p2p.py index adbc7bd..911dfce 100644 --- a/apt-p2p.py +++ b/apt-p2p.py @@ -1,13 +1,14 @@ -#!/usr/bin/env python +#!/usr/bin/python -# Load apt-p2p application -# -# There are two ways apt-p2p can be started: -# 1. twistd -y apt-p2p -# - twistd will load this file and execute the app -# in 'application' variable -# 2. from command line -# - __name__ will be '__main__' +"""Load the apt-p2p application. + +There are two ways apt-p2p can be started: + 1. twistd -y apt-p2p + - twistd will load this file and execute the app + in 'application' variable + 2. from command line + - __name__ will be '__main__' +""" import pwd,sys @@ -58,32 +59,32 @@ try: except: uid,gid = None,None -log.msg('Starting application') +log.msg('Starting application with uid/gid %r/%r' % (uid, gid)) application = service.Application("apt-p2p", uid, gid) #print service.IProcess(application).processName #service.IProcess(application).processName = 'apt-p2p' -log.msg('Starting DHT') DHT = __import__(config.get('DEFAULT', 'DHT')+'.DHT', globals(), locals(), ['DHT']) assert IDHT.implementedBy(DHT.DHT), "You must provide a DHT implementation that implements the IDHT interface." if not config.getboolean('DEFAULT', 'DHT-only'): log.msg('Starting main application server') from apt_p2p.apt_p2p import AptP2P - myapp = AptP2P(DHT.DHT) - factory = myapp.getHTTPFactory() + factory = AptP2P(DHT.DHT) s = strports.service('tcp:'+config.get('DEFAULT', 'port'), factory) s.setServiceParent(application) else: + log.msg('Starting the DHT') myDHT = DHT.DHT() + if IDHTStatsFactory.implementedBy(DHT.DHT): log.msg("Starting the DHT's HTTP stats displayer") factory = myDHT.getStatsFactory() s = strports.service('tcp:'+config.get('DEFAULT', 'port'), factory) s.setServiceParent(application) - myDHT.loadConfig(config, config.get('DEFAULT', 'DHT')) - myDHT.join() + reactor.callLater(0, myDHT.loadConfig, config, config.get('DEFAULT', 'DHT')) + reactor.callLater(0, myDHT.join) if __name__ == '__main__': # Run on command line