def serve(ctx, handlers, prerun=prerun, postrun=postrun): """ Start protocol at socket address path. Handlers is a dict of sub-command names, and corresponding functions. See above for the two callbacks prerun and postrun. """ address = FilePath(ctx.opts.flags.address) if address.exists(): raise SystemExit("Cannot listen on an existing path") #startLogging(sys.stdout) serverFactory = Factory() serverFactory.ctx = ctx serverFactory.handlers = handlers serverFactory.prerun = prerun serverFactory.postrun = postrun serverFactory.protocol = ServerProtocol port = reactor.listenUNIX(address.path, serverFactory) reactor.run()