ds_class = util.import_module_class(ds) ds_kwargs = config['data_server']['data_source_config'].get(ds, {}) ds_instance = ds_class( **ds_kwargs) # args only used by StatMonsterRRD atm key = hashlib.sha1(ds).hexdigest()[:6] ds_instance._FF_KEY = key config['data_server']['data_sources_by_key'][key] = ds_instance return ds_instance for ds in config['data_server']['data_sources']: ds_instance = get_ds_instance(ds) data_sources.append(ds_instance) log.debug('Using datasource %s' % type(ds_instance).__name__) config["data_server"]["data_sources"] = data_sources if not options.omit_data_server: # Allow the data server to initialize itself and attach itself to the IOLoop initialize_data_server(config["data_server"], secret_key=config["secret_key"], ioloop=tornado.ioloop.IOLoop.instance()) if not options.omit_ui_server: # Allow the UI server to initialize itself and attach itself to the IOLoop initialize_ui_server(config["ui_server"], secret_key=config["secret_key"], ioloop=tornado.ioloop.IOLoop.instance()) # Kick everything off tornado.ioloop.IOLoop.instance().start()
if "secret_key" not in config.keys(): log.error("No Secret Key Provided: Exiting") sys.exit(1) if not options.omit_data_server: # Allow the data server to initialize itself and attach itself to the IOLoop try: initialize_data_server(config, secret_key=config["secret_key"]) except socket.error as exc: log.error('Problem starting data server: %s' % str(exc)) sys.exit(1) if not options.omit_ui_server: # Allow the UI server to initialize itself and attach itself to the IOLoop try: initialize_ui_server(config, secret_key=config["secret_key"]) except socket.error as exc: # The following hack is unfortunate, but necessary. # When Tornado forks, its does the right thing when an HTTP server # is configured to have as many workers as procs that gets forked. # However, if another HTTPServer is on the IOLoop, it will fail to # bind to the right address somewhere in the process. # This is OK, because the predecessor procs will live on and serve # traffic correctly. # This has the unfortunate side-effect of masking instances in # development when users accidentally try to start multiple # instances of Firefly running. The following warning message is # intended to provide a hint for this case in development, and can # be safely ignored in production. if "Address already in use" in str(exc): log.warning("UI server socket not bound: %s. This is probably due to multi-processing and can safely be ignored." % str(exc))
if "secret_key" not in config.keys(): log.error("No Secret Key Provided: Exiting") sys.exit(1) if not options.omit_data_server: # Allow the data server to initialize itself and attach itself to the IOLoop try: initialize_data_server(config["data_server"], secret_key=config["secret_key"]) except socket.error as exc: log.error('Problem starting data server: %s' % str(exc)) sys.exit(1) if not options.omit_ui_server: # Allow the UI server to initialize itself and attach itself to the IOLoop try: initialize_ui_server(config["ui_server"], secret_key=config["secret_key"]) except socket.error as exc: # The following hack is unfortunate, but necessary. # When Tornado forks, its does the right thing when an HTTP server # is configured to have as many workers as procs that gets forked. # However, if another HTTPServer is on the IOLoop, it will fail to # bind to the right address somewhere in the process. # This is OK, because the predecessor procs will live on and serve # traffic correctly. # This has the unfortunate side-effect of masking instances in # development when users accidentally try to start multiple # instances of Firefly running. The following warning message is # intended to provide a hint for this case in development, and can # be safely ignored in production. if "Address already in use" in str(exc): log.warning("UI server socket not bound: %s. This is probably due to multi-processing and can safely be ignored." % str(exc))
data_sources = [] # mix in the configured data sources to the data server configuration def get_ds_instance(ds): ds_class = util.import_module_class(ds) ds_kwargs = config['data_server']['data_source_config'].get(ds, {}) ds_instance = ds_class(**ds_kwargs) # args only used by StatMonsterRRD atm key = hashlib.sha1(ds).hexdigest()[:6] ds_instance._FF_KEY = key config['data_server']['data_sources_by_key'][key] = ds_instance return ds_instance for ds in config['data_server']['data_sources']: ds_instance = get_ds_instance(ds) data_sources.append(ds_instance) log.debug('Using datasource %s' % type(ds_instance).__name__) config["data_server"]["data_sources"] = data_sources if not options.omit_data_server: # Allow the data server to initialize itself and attach itself to the IOLoop initialize_data_server(config["data_server"], secret_key=config["secret_key"], ioloop=tornado.ioloop.IOLoop.instance()) if not options.omit_ui_server: # Allow the UI server to initialize itself and attach itself to the IOLoop initialize_ui_server(config["ui_server"], secret_key=config["secret_key"], ioloop=tornado.ioloop.IOLoop.instance()) # Kick everything off tornado.ioloop.IOLoop.instance().start()