def ClientInit(): """Run all startup routines for the client.""" if stats.STATS is None: stats.STATS = stats.StatsCollector() config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() client_logging.LogInit() registry.Init() if not config.CONFIG.ContextApplied(contexts.CLIENT_BUILD_CONTEXT): config.CONFIG.Persist("Client.labels") config.CONFIG.Persist("Client.proxy_servers") config.CONFIG.Persist("Client.tempdir_roots")
def Init(): """Run all required startup routines and initialization hooks.""" global INIT_RAN if INIT_RAN: return # Set up a temporary syslog handler so we have somewhere to log problems # with ConfigInit() which needs to happen before we can start our create our # proper logging setup. syslog_logger = logging.getLogger("TempLogger") if os.path.exists("/dev/log"): handler = logging.handlers.SysLogHandler(address="/dev/log") else: handler = logging.handlers.SysLogHandler() syslog_logger.addHandler(handler) try: config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() except config_lib.Error: syslog_logger.exception("Died during config initialization") raise metric_metadata = server_metrics.GetMetadata() metric_metadata.extend(communicator.GetMetricMetadata()) stats_collector = prometheus_stats_collector.PrometheusStatsCollector( metric_metadata, registry=prometheus_client.REGISTRY) stats_collector_instance.Set(stats_collector) server_logging.ServerLoggingStartupInit() bs_registry_init.RegisterBlobStores() all_decoders.Register() all_parsers.Register() registry.Init() # Exempt config updater from this check because it is the one responsible for # setting the variable. if not config.CONFIG.ContextApplied("ConfigUpdater Context"): if not config.CONFIG.Get("Server.initialized"): raise RuntimeError( "Config not initialized, run \"grr_config_updater" " initialize\". If the server is already configured," " add \"Server.initialized: True\" to your config.") INIT_RAN = True
def Init(): """Run all required startup routines and initialization hooks.""" global INIT_RAN if INIT_RAN: return # Set up a temporary syslog handler so we have somewhere to log problems # with ConfigInit() which needs to happen before we can start our create our # proper logging setup. syslog_logger = logging.getLogger("TempLogger") if os.path.exists("/dev/log"): handler = logging.handlers.SysLogHandler(address="/dev/log") else: handler = logging.handlers.SysLogHandler() syslog_logger.addHandler(handler) try: config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() except config_lib.Error: syslog_logger.exception("Died during config initialization") raise if hasattr(registry_init, "stats"): logging.debug("Using local stats collector.") stats.STATS = registry_init.stats.StatsCollector() else: logging.debug("Using default stats collector.") stats.STATS = stats.StatsCollector() threadpool.InitializeMetrics() server_logging.ServerLoggingStartupInit() registry.Init() # Exempt config updater from this check because it is the one responsible for # setting the variable. if not config.CONFIG.ContextApplied("ConfigUpdater Context"): if not config.CONFIG.Get("Server.initialized"): raise RuntimeError( "Config not initialized, run \"grr_config_updater" " initialize\". If the server is already configured," " add \"Server.initialized: True\" to your config.") INIT_RAN = True
def ClientInit(): """Run all startup routines for the client.""" metric_metadata = client_metrics.GetMetadata() metric_metadata.extend(communicator.GetMetricMetadata()) stats_collector_instance.Set( default_stats_collector.DefaultStatsCollector(metric_metadata)) config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() client_logging.LogInit() all_parsers.Register() registry.Init() if not config.CONFIG.ContextApplied(contexts.CLIENT_BUILD_CONTEXT): config.CONFIG.Persist("Client.labels") config.CONFIG.Persist("Client.proxy_servers") config.CONFIG.Persist("Client.tempdir_roots")