def run_server(log_level=logging.INFO, config_file=''): log = make_log(debug=log_level == logging.DEBUG, log_level=log_level) # For the debugging purposes log.info('Genesis %s' % version()) # We need this early genesis.utils.logger = log # Read config config = Config() if config_file: log.info('Using config file %s' % config_file) config.load(config_file) else: log.info('Using default settings') # Handle first-launch reconfiguration deployed.reconfigure(config) # Add log handler to config, so all plugins could access it config.set('log_facility', log) # Start recording log for the bug reports log.blackbox.start() arch = genesis.utils.detect_architecture() log.info('Detected architecture/hardware: %s, %s' % (arch[0], arch[1])) platform = genesis.utils.detect_platform() log.info('Detected platform: %s' % platform) # Load external plugins PluginLoader.initialize(log, config.get('genesis', 'plugins'), arch[0], platform) PluginLoader.load_plugins() # Start components app = Application(config) PluginLoader.register_mgr(app) # Register permanent app ComponentManager.create(app) # Check system time log.info('Verifying system time...') os = 0 try: st = genesis.utils.SystemTime() os = st.get_offset() except Exception, e: log.error('System time could not be retrieved. Error: %s' % str(e))
def run_server(log_level=logging.INFO, config_file=''): log = make_log(debug=log_level==logging.DEBUG, log_level=log_level) # For the debugging purposes log.info('Genesis %s' % version()) # We need this early genesis.utils.logger = log # Read config config = Config() if config_file: log.info('Using config file %s'%config_file) config.load(config_file) else: log.info('Using default settings') # Handle first-launch reconfiguration deployed.reconfigure(config) # Add log handler to config, so all plugins could access it config.set('log_facility',log) # Start recording log for the bug reports log.blackbox.start() arch = genesis.utils.detect_architecture() log.info('Detected architecture/hardware: %s, %s'%(arch[0],arch[1])) platform = genesis.utils.detect_platform() log.info('Detected platform: %s'%platform) # Load external plugins PluginLoader.initialize(log, config.get('genesis', 'plugins'), arch[0], platform) PluginLoader.load_plugins() # Start components app = Application(config) PluginLoader.register_mgr(app) # Register permanent app ComponentManager.create(app) # Check system time log.info('Verifying system time...') os = 0 try: st = genesis.utils.SystemTime() os = st.get_offset() except Exception, e: log.error('System time could not be retrieved. Error: %s' % str(e))
def run_server(log_level=logging.INFO, config_file=''): log = make_log(debug=log_level==logging.DEBUG, log_level=log_level) # For the debugging purposes log.info('Genesis %s' % version()) # We need this early genesis.utils.logger = log # Read config config = Config() if config_file: log.info('Using config file %s'%config_file) config.load(config_file) else: log.info('Using default settings') # Handle first-launch reconfiguration deployed.reconfigure(config) # Add log handler to config, so all plugins could access it config.set('log_facility',log) # Start recording log for the bug reports log.blackbox.start() platform = genesis.utils.detect_platform() log.info('Detected platform: %s'%platform) # Load external plugins PluginLoader.initialize(log, config.get('genesis', 'plugins'), platform) PluginLoader.load_plugins() # Start components app = Application(config) PluginLoader.register_mgr(app) # Register permanent app ComponentManager.create(app) # Make sure correct kernel modules are enabled genesis.utils.shell('modprobe ip_tables') # Start server host = config.get('genesis','bind_host') port = config.getint('genesis','bind_port') log.info('Listening on %s:%d'%(host, port)) # SSL params ssl = {} if config.getint('genesis', 'ssl') == 1: ssl = { 'keyfile': config.get('genesis','cert_key'), 'certfile': config.get('genesis','cert_file'), } log.info('Using HTTP server: %s'%http_server) server = WSGIServer( (host, port), application=AppDispatcher(config).dispatcher, **ssl ) config.set('server', server) try: syslog.openlog( ident='genesis', facility=syslog.LOG_AUTH, ) except: syslog.openlog('genesis') log.info('Starting server') server.serve_forever() ComponentManager.get().stop() if hasattr(server, 'restart_marker'): log.info('Restarting by request') fd = 20 # Close all descriptors. Creepy thing while fd > 2: try: os.close(fd) log.debug('Closed descriptor #%i'%fd) except: pass fd -= 1 os.execv(sys.argv[0], sys.argv) else: log.info('Stopped by request')
def run_server(log_level=logging.INFO, config_file=''): log = make_log(debug=log_level == logging.DEBUG, log_level=log_level) # For the debugging purposes log.info('Genesis %s' % version()) # We need this early genesis.utils.logger = log # Read config config = Config() if config_file: log.info('Using config file %s' % config_file) config.load(config_file) else: log.info('Using default settings') # Handle first-launch reconfiguration deployed.reconfigure(config) # Add log handler to config, so all plugins could access it config.set('log_facility', log) # Start recording log for the bug reports log.blackbox.start() platform = genesis.utils.detect_platform() log.info('Detected platform: %s' % platform) # Load external plugins PluginLoader.initialize(log, config.get('genesis', 'plugins'), platform) PluginLoader.load_plugins() # Start components app = Application(config) PluginLoader.register_mgr(app) # Register permanent app ComponentManager.create(app) # Make sure correct kernel modules are enabled genesis.utils.shell('modprobe ip_tables') # Start server host = config.get('genesis', 'bind_host') port = config.getint('genesis', 'bind_port') log.info('Listening on %s:%d' % (host, port)) # SSL params ssl = {} if config.getint('genesis', 'ssl') == 1: ssl = { 'keyfile': config.get('genesis', 'cert_key'), 'certfile': config.get('genesis', 'cert_file'), } log.info('Using HTTP server: %s' % http_server) server = WSGIServer((host, port), application=AppDispatcher(config).dispatcher, **ssl) config.set('server', server) try: syslog.openlog( ident='genesis', facility=syslog.LOG_AUTH, ) except: syslog.openlog('genesis') log.info('Starting server') server.serve_forever() ComponentManager.get().stop() if hasattr(server, 'restart_marker'): log.info('Restarting by request') fd = 20 # Close all descriptors. Creepy thing while fd > 2: try: os.close(fd) log.debug('Closed descriptor #%i' % fd) except: pass fd -= 1 os.execv(sys.argv[0], sys.argv) else: log.info('Stopped by request')