def start(args): """ Starts the aggregator :port: Port to listen on for reporters """ publisher = Publisher() defaults = {"ip": "127.0.0.1", "port": 13337, "modules": {"Redis": [{}], "Websocket": [{}]}} # If no config file use dummy data if args.configFile: config = parseConfig(args.configFile, defaults=defaults) else: config = defaults # Load modules based on config loadModulesFromConfig(config, publisher, moduleFinder) # If args.port override other port config if args.port: config["port"] = args.port # Create server server = Server(config["port"], publisher) publisher.start() server.listen() # Wait for the server to finish up server.serverGreenlet.join()
def start(args): """ Starts the reporter :address: Aggregator to connect to :hostname: Hostname """ # Modules will be completely overwritten but that's as intended defaults = { 'hostname': socket.gethostname(), 'host' : '127.0.0.1', 'port' : 13337, 'modules' : { 'Network': [ {} ] } } # If no config file use dummy data if args.configFile: config = parseConfig(args.configFile, defaults = defaults) else: config = defaults if args.port: config["port"] = args.port if args.host: config["host"] = args.host if args.hostname: config['hostname'] = args.hostname # Initialize networking client client = Client((config["host"], config["port"])) # Create target function target = functools.partial(send_publish_socket, additional = { "host": config['hostname'] }, client = client) # Initialize the publisher publisher = Publisher(target) # Load modules loadModulesFromConfig(config, publisher, moduleFinder) # Start client and publisher client.connect() publisher.start() # Wait until client finishes try: client.finished.wait() except KeyboardInterrupt: client.disconnect() client.finished.wait()