def init(self, args, db, hosts, logger): self.args = args self.db = db self.hosts = hosts self.logger = logger self.bind = args.bind self.forward = args.forward self.peers = {} self.requests = {} self.cache = LRUCache(maxsize=args.cachesize) if args.daemon: Daemon(args.pidfile).register(self) if args.debug: Debugger(events=args.verbose, logger=logger).register(self) self.transport = UDPServer(self.bind).register(self) self.protocol = DNS().register(self)
def main(): config = Config() logger = setup_logging(config) db = setup_database(config, logger) manager = Manager() Worker(channel="threadpool").register(manager) if config["debug"]: Debugger( logger=logger, events=config["verbose"], ).register(manager) if config["daemon"]: Daemon(config["pidfile"]).register(manager) Core(config, db).register(manager) manager.run()
def main(): opts, args = parse_options() source = sanitize(args[0]) target = sanitize(args[1]) if type(source) is not tuple: print("ERROR: source address must specify port (address:port)") raise SystemExit(-1) if type(target) is not tuple: print("ERROR: target address must specify port (address:port)") raise SystemExit(-1) system = PortForwarder(source, target) if opts.daemon: Daemon("portforward.pid").register(system) if opts.debug: Debugger().register(system) system.run()
def init(self, host, port=6667, opts=None): self.host = host self.port = port self.opts = opts self.hostname = gethostname() self.nick = opts.nick self.ircchannels = opts.channels # Mapping of IRC Channel -> Set of Nicks self.chanmap = defaultdict(set) # Mapping of Nick -> Set of IRC Channels self.nickmap = defaultdict(set) # Debugger Debugger(events=opts.verbose).register(self) # Add TCPClient and IRC to the system. self.transport = TCPClient(channel=self.channel).register(self) self.protocol = IRC(channel=self.channel).register(self) # Logger(s) for ircchannel in self.ircchannels: if not path.exists(path.join(opts.output, ircchannel)): makedirs(path.join(opts.output, ircchannel)) Logger(path.join(opts.output, generate_logfile(ircchannel)), "a", channel="logger.{0:s}".format(ircchannel)).register(self) # Daemon? if self.opts.daemon: Daemon(opts.pidfile).register(self) # Keep-Alive Timer Timer(60, Event.create("keepalive"), persist=True).register(self)
def add_daemonizing(self): if self.arguments.daemonize: self += Daemon(self.arguments.pidfile, os.getcwd())
def started(self, *args): Daemon(self.pidfile).register(self)
def main(): config = Config() manager = Manager() if config.get("debug"): manager += Debugger( events=config.get("verbose"), file=config.get("errorlog"), ) environ = Environment(config) SignalHandler(environ).register(environ) manager += environ if config.get("sock") is not None: bind = config.get("sock") elif ":" in config.get("bind"): address, port = config.get("bind").split(":") bind = ( address, int(port), ) else: bind = ( config.get("bind"), config.get("port"), ) server = (Server(bind) + Sessions() + Root(environ) + CacheControl(environ) + ErrorHandler(environ)) if MemoryMonitor is not None: MemoryMonitor(channel="/memory").register(server) if not config.get("disable-logging"): server += Logger(file=config.get("accesslog", sys.stdout)) if not config.get("disable-static"): server += Static(docroot=os.path.join(config.get("theme"), "htdocs")) if not config.get("disable-hgweb"): baseui = ui() baseui.setconfig("web", "prefix", "/+hg") baseui.setconfig("web", "style", "gitweb") baseui.setconfig("web", "allow_push", "*") baseui.setconfig("web", "push_ssl", False) baseui.setconfig("web", "allow_archive", ["bz2", "gz", "zip"]) baseui.setconfig("web", "description", config.get("description")) server += Gateway({ "/+hg": hgweb(environ.storage.repo_path, config.get("name"), baseui) }) if not config.get("disable-compression"): server += Compression(environ) if config.get("daemon"): manager += Daemon(config.get("pidfile")) server.register(manager) manager.run()
def init(self, pidfile, signalfile): self.pidfile = pidfile self.signalfile = signalfile Daemon(self.pidfile).register(self)
def init(self, pidfile, **kwargs): Daemon(pidfile, **kwargs).register(self)