def run_server(config_file=""): if config_file != "": config_dir = os.path.dirname(config_file) if (not os.path.exists(config_dir)) or (not os.path.isdir(config_dir)): print "Error in the config file." else: config_dir = os.getcwd() + "/configs" config_file = config_dir + "/genesis2.conf" make_log(config_dir) logger = logging.getLogger("genesis2") logger.info("Genesis %s" % version()) if os.path.isfile(config_file): logger.info("Using config file %s" % config_file) else: # Shutdown logger.critical("The %s is not a file." % config_file) exit(-1) # Read config config = Config() if os.path.exists(config_file) and os.path.isfile(config_file): config.load(config_file) else: logger.critical("The %s doesn't exist" % config_file) exit(-1) # (kudrom) TODO: I should delete the GenesisManager and substitute it with a Plugin GenesisManager(config) platform = detect_platform() logger.info("Detected platform: %s" % platform) # Load plugins import genesis2.plugins # Load apps path_apps = config.get("genesis2", "path_apps", None) if path_apps is None: path_apps = os.getcwd() + "/apps" logger.info("Using %s as path apps." % path_apps) appmgr = AppManager(path_apps=path_apps) appmgr.load_apps() # (kudrom) TODO: Register a new ComponentMgr # (kudrom) TODO: we should use an iptables plugin # Make sure correct kernel modules are enabled # genesis2.utils.shell('modprobe ip_tables') if not hasattr(genesis2.apis, "PGenesis2Server"): logger.error("There's no plugin for PGenesis2Server registered in the system") exit(-1) # The server is a plugin to ease its replacement logger.info("Starting server") server = getattr(genesis2.apis, "PGenesis2Server") server.initialize(config) server.serve_forever()
def __init__(self): ConfigParser.__init__(self) # TODO: move this out; (kudrom) -> it should be in the installer self.set('platform', detect_platform())