static void Main(string[] args) { // get configuration var rabbitMQConfigSection = Config.GetSection("RabbitMQ"); string host = rabbitMQConfigSection["Host"]; string userName = rabbitMQConfigSection["UserName"]; string password = rabbitMQConfigSection["Password"]; var auditlogConfigSection = Config.GetSection("Auditlog"); string logPath = auditlogConfigSection["path"]; // start auditlog manager RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "Auditlog", ""); AuditLogManager manager = new AuditLogManager(messageHandler, logPath); manager.Start(); if (_env == "Development") { Console.WriteLine("Auditlog service started. Press any key to stop..."); Console.ReadKey(true); manager.Stop(); } else { Console.WriteLine("AuditLog service started."); while (true) { Thread.Sleep(10000); } } }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("AuditlogServiceType", context => new AuditlogService(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(AuditlogService).Name); // get configuration var rabbitMQConfigSection = Config.GetSection("RabbitMQ"); string host = rabbitMQConfigSection["Host"]; string userName = rabbitMQConfigSection["UserName"]; string password = rabbitMQConfigSection["Password"]; var auditlogConfigSection = Config.GetSection("Auditlog"); string logPath = auditlogConfigSection["path"]; // start auditlog manager RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "Auditlog", ""); AuditLogManager manager = new AuditLogManager(messageHandler, logPath); manager.Start(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }