/// <inheritdoc /> public void Initialize() { LoggerManagement.ActivateLogging(this); _container = new LocalContainer(); _portConfig = ConfigManager.GetConfiguration <PortConfig>(); _container.Register <IVersionService, VersionService>(nameof(VersionService), LifeCycle.Transient); _container.Register <EndpointCollector, EndpointCollector>(); var collector = _container.Resolve <EndpointCollector>(); _container.Extend <WcfFacility>(); _container.Register <ITypedHostFactory, TypedHostFactory>(); var factory = _container.Resolve <ITypedHostFactory>(); var host = new ConfiguredServiceHost(factory, Logger, collector, _portConfig); var hostConfig = new HostConfig { Endpoint = "endpoints", MetadataEnabled = true }; host.Setup(typeof(IVersionService), hostConfig); host.Start(); }
/// <inheritdoc /> public virtual void Initialize() { Container = ContainerFactory.Create(new Dictionary <Type, string>(), GetType().Assembly) .Register <IParallelOperations, ParallelOperations>(); Config = ConfigProvider.GetModuleConfiguration <TConf>(ModuleName); //add several components to internal container Container.SetInstance(ConfigProvider) .SetInstance(ClientFactoy) .SetInstance(Config) .SetInstance(UserInfoProvider); AdditionalInitialize(); LoggerManagement.ActivateLogging(this); Logger.Log(LogLevel.Info, "{0} is initializing...", ModuleName); Container.SetInstance(Logger); OnInitialize(); // Execute SubInitializer var subInits = Container.ResolveAll <ISubInitializer>() ?? new ISubInitializer[0]; foreach (var subInitializer in subInits) { subInitializer.Initialize(Container); } }
void IServerModuleStateContext.Initialize() { // Activate logging LoggerManagement.ActivateLogging(this); LoggerManagement.AppendListenerToStream(ProcessLogMessage, LogLevel.Warning, Name); Logger.Log(LogLevel.Info, "{0} is initializing...", Name); // Get config and parse for container settings Config = ConfigManager.GetConfiguration <TConf>(); ConfigParser.ParseStrategies(Config, Strategies); // Initialize container with server module dll and this dll Container = ContainerFactory.Create(Strategies, GetType().Assembly) .Register <IParallelOperations, ParallelOperations>() // Register instances for this cycle .SetInstance(Config).SetInstance(Logger); OnInitialize(); // Execute SubInitializer var subInits = Container.ResolveAll <ISubInitializer>() ?? new ISubInitializer[0]; foreach (var subInitializer in subInits) { subInitializer.Initialize(Container); } Logger.Log(LogLevel.Info, "{0} initialized!", Name); // After initializing the module, all notifications are unnecessary Notifications.Clear(); }
public override void Dispose() { lock (_remoteAppenders) { foreach (var remoteAppender in _remoteAppenders.Values) { LoggerManagement.RemoveListenerFromStream(remoteAppender.BufferMessage); } _remoteAppenders.Clear(); } base.Dispose(); }
void IServerModuleStateContext.Destruct() { // Destroy local container if (Container != null) { Container.Destroy(); Container = null; } // Deregister from logging LoggerManagement.RemoveListenerFromStream(ProcessLogMessage); LoggerManagement.DeactivateLogging(this); Logger.Log(LogLevel.Info, "{0} destructed!", Name); }
/// <summary> /// Remove a remote appender from the logging stream /// </summary> /// <param name="appenderId"></param> public void RemoveRemoteLogAppender(int appenderId) { RemoteAppender appender; lock (_remoteAppenders) appender = _remoteAppenders.ContainsKey(appenderId) ? _remoteAppenders[appenderId] : null; if (appender == null) { return; } LoggerManagement.RemoveListenerFromStream(appender.BufferMessage); }
/// <inheritdoc /> public void Initialize() { LoggerManagement.ActivateLogging(this); _container = new LocalContainer(); var factoryConfig = ConfigManager.GetConfiguration <HostFactoryConfig>(); _portConfig = ConfigManager.GetConfiguration <PortConfig>(); // In minimal core setups with no WCF service this can be disabled if (factoryConfig.VersionServiceDisabled) { return; } var hostConfig = new HostConfig { BindingType = ServiceBindingType.BasicHttp, Endpoint = "ServiceVersions", MetadataEnabled = true }; _container.Register <IVersionService, VersionService>(nameof(VersionService), LifeCycle.Transient); _container.Register <IEndpointCollector, EndpointCollector>(); var collector = _container.Resolve <IEndpointCollector>(); _container.Extend <WcfFacility>(); _container.Register <ITypedHostFactory, TypedHostFactory>(); var factory = _container.Resolve <ITypedHostFactory>(); var host = new ConfiguredServiceHost(factory, Logger, collector, _portConfig); host.Setup <IVersionService>(hostConfig); host.Start(); hostConfig = new HostConfig { Endpoint = "ServiceVersionsWeb", MetadataEnabled = true }; host = new ConfiguredServiceHost(factory, Logger, collector, _portConfig); host.Setup <IVersionService>(hostConfig); host.Start(); }
private void CheckDeadAppender() { IEnumerable <KeyValuePair <int, RemoteAppender> > appenders; lock (_remoteAppenders) { appenders = _remoteAppenders.Where(appender => (DateTime.Now - appender.Value.LastFlush).TotalMilliseconds > Config.AppenderTimeOut) .ToArray(); } foreach (var appender in appenders) { LoggerManagement.RemoveListenerFromStream(appender.Value.BufferMessage); } lock (_remoteAppenders) { foreach (var appender in appenders) { _remoteAppenders.Remove(appender.Key); } } }
/// <summary> /// Initialize the module manager. /// </summary> public void Initialize() { // Create components LoggerManagement.ActivateLogging(this); _config = ConfigManager.GetConfiguration <ModuleManagerConfig>(); // Create dependency manager and build tree of available modules _dependencyManager = new ModuleDependencyManager(Logger.GetChild(string.Empty, typeof(ModuleDependencyManager))); var availableModules = _dependencyManager.BuildDependencyTree(ServerModules); // Create dedicated components for stopping and starting var waitingModules = new Dictionary <IServerModule, ICollection <IServerModule> >(); _moduleStarter = new ModuleStarter(_dependencyManager, Logger.GetChild(string.Empty, typeof(ModuleStarter)), _config) { AvailableModules = availableModules, WaitingModules = waitingModules }; _moduleStopper = new ModuleStopper(_dependencyManager, Logger.GetChild(string.Empty, typeof(ModuleStopper))) { AvailableModules = availableModules, WaitingModules = waitingModules }; // Link framework modules foreach (var platformModule in availableModules.OfType <IPlatformModule>()) { platformModule.SetModuleManager(this); } // Observe state changed events of modules foreach (var module in availableModules) { module.StateChanged += OnModuleStateChanged; } AllModules = ServerModules; }
/// <summary> /// Add a remote appender to the logging stream /// </summary> public int AddRemoteLogAppender(string name, LogLevel level) { Logger.Log(LogLevel.Info, "Added appender with name {0} and level {1}", name, level); var appender = new RemoteAppender(); if (string.IsNullOrEmpty(name) && level == LogLevel.Trace) { LoggerManagement.AppendListenerToStream(appender.BufferMessage); } else if (string.IsNullOrEmpty(name)) { LoggerManagement.AppendListenerToStream(appender.BufferMessage, level); } else if (level == LogLevel.Trace) { LoggerManagement.AppendListenerToStream(appender.BufferMessage, name); } else { LoggerManagement.AppendListenerToStream(appender.BufferMessage, level, name); } var id = 1; lock (_remoteAppenders) { int[] takenIds = _remoteAppenders.Keys.ToArray(); // Find first non taken id while (takenIds.Contains(id)) { id++; } _remoteAppenders[id] = appender; } return(id); }
public InvocationResponse SetLogLevel(string loggerName, SetLogLevelRequest request) { LoggerManagement.SetLevel(loggerName, request.Level); return new InvocationResponse(); }
public LoggerModel[] GetAllLoggers() { return LoggerManagement.Select(Convert).ToArray(); }