private static void Main(string[] args) { var isDebuggerMode = IsDebuggerMode(args); if (isDebuggerMode && !Debugger.IsAttached) { Debugger.Launch(); } var settingsContainer = new ReplicationServiceSettings(); var environmentSettings = settingsContainer.AsSettings <IEnvironmentSettings>(); var connectionStringSettings = settingsContainer.AsSettings <IConnectionStringSettings>(); var tracerContextEntryProviders = new ITracerContextEntryProvider[] { new TracerContextConstEntryProvider(TracerContextKeys.Required.Environment, environmentSettings.EnvironmentName), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPoint, environmentSettings.EntryPointName), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointHost, NetworkInfo.ComputerFQDN), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointInstanceId, Guid.NewGuid().ToString()), new TracerContextSelfHostedEntryProvider(TracerContextKeys.Required.UserAccount) }; var tracerContextManager = new TracerContextManager(tracerContextEntryProviders); var tracer = Log4NetTracerBuilder.Use .DefaultXmlConfig .Console .EventLog .Logstash(new Uri(connectionStringSettings.GetConnectionString(LoggingConnectionStringIdentity.Instance))) .Build; IUnityContainer container = null; try { container = Bootstrapper.ConfigureUnity(settingsContainer, tracer, tracerContextManager); var schedulerManager = container.Resolve <ISchedulerManager>(); if (IsConsoleMode(args)) { schedulerManager.Start(); Console.WriteLine("Advanced Search Replication service successfully started."); Console.WriteLine("Press ENTER to stop..."); Console.ReadLine(); Console.WriteLine("Advanced Search Replication service is stopping..."); schedulerManager.Stop(); Console.WriteLine("Advanced Search Replication service stopped successfully. Press ENTER to exit..."); Console.ReadLine(); } else { using (var replicationService = new ReplicationService(schedulerManager)) { ServiceBase.Run(replicationService); } } } finally { if (container != null) { container.Dispose(); } } }
private static void Main(string[] args) { var isDebuggerMode = IsDebuggerMode(args); if (isDebuggerMode && !Debugger.IsAttached) { Debugger.Launch(); } var settingsContainer = new ReplicationServiceSettings(); var environmentSettings = settingsContainer.AsSettings<IEnvironmentSettings>(); var connectionStringSettings = settingsContainer.AsSettings<IConnectionStringSettings>(); var tracer = Log4NetTracerBuilder.Use .ApplicationXmlConfig .Console .EventLog .WithGlobalProperties(x => x.Property(TracerContextKeys.Tenant, environmentSettings.EnvironmentName) .Property(TracerContextKeys.EntryPoint, environmentSettings.EntryPointName) .Property(TracerContextKeys.EntryPointHost, NetworkInfo.ComputerFQDN) .Property(TracerContextKeys.EntryPointInstanceId, Guid.NewGuid().ToString())) .Logstash(new Uri(connectionStringSettings.GetConnectionString(LoggingConnectionStringIdentity.Instance)), appender => { appender.LogstashLayout.IncrementalCounter = true; } ) .Build; IUnityContainer container = null; try { container = Bootstrapper.ConfigureUnity(settingsContainer, tracer); var schedulerManagers = container.ResolveAll<ISchedulerManager>().ToList(); if (IsConsoleMode(args)) { foreach (var schedulerManager in schedulerManagers) { schedulerManager.Start(); } Console.WriteLine("ERM Validation Rules Replication service successfully started."); Console.WriteLine("Press ENTER to stop..."); Console.ReadLine(); Console.WriteLine("ERM Validation Rules Replication service is stopping..."); foreach (var schedulerManager in schedulerManagers) { schedulerManager.Stop(); } Console.WriteLine("ERM Validation Rules Replication service stopped successfully. Press ENTER to exit..."); Console.ReadLine(); } else { using (var replicationService = new ReplicationService(schedulerManagers)) { ServiceBase.Run(replicationService); } } } finally { container?.Dispose(); } }