diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_custom_check_fails.cs b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_custom_check_fails.cs index 23b5594798..5926ba1ac0 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_custom_check_fails.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_custom_check_fails.cs @@ -41,7 +41,7 @@ public class MyContext : ScenarioContext; public class EndpointWithFailingCustomCheck : EndpointConfigurationBuilder { - public EndpointWithFailingCustomCheck() => EndpointSetup(c => { c.ReportCustomChecksTo(Settings.DEFAULT_SERVICE_NAME, TimeSpan.FromSeconds(1)); }); + public EndpointWithFailingCustomCheck() => EndpointSetup(c => { c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); }); class FailingCustomCheck() : CustomCheck("MyCustomCheckId", "MyCategory") { diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_periodic_custom_check_fails.cs b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_periodic_custom_check_fails.cs index cd6ae00151..b1da854424 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_periodic_custom_check_fails.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_a_periodic_custom_check_fails.cs @@ -121,7 +121,7 @@ protected override async Task OnStart(IMessageSession session, CancellationToken public class WithCustomCheck : EndpointConfigurationBuilder { - public WithCustomCheck() => EndpointSetup(c => { c.ReportCustomChecksTo(Settings.DEFAULT_SERVICE_NAME, TimeSpan.FromSeconds(1)); }); + public WithCustomCheck() => EndpointSetup(c => { c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); }); class FailingCustomCheck(MyContext context) : NServiceBus.CustomChecks.CustomCheck("MyCustomCheckId", "MyCategory", TimeSpan.FromSeconds(5)) diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_critical_storage_threshold_reached.cs b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_critical_storage_threshold_reached.cs index ffb026a871..f7fa1ac290 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_critical_storage_threshold_reached.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_critical_storage_threshold_reached.cs @@ -99,7 +99,7 @@ public class Sender : EndpointConfigurationBuilder public Sender() => EndpointSetup(c => { - c.ReportCustomChecksTo(Settings.DEFAULT_SERVICE_NAME, TimeSpan.FromSeconds(1)); + c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); c.NoRetries(); }); diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_custom_check_events_are_triggered.cs b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_custom_check_events_are_triggered.cs index ded109fe19..b5a34e5730 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_custom_check_events_are_triggered.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_custom_check_events_are_triggered.cs @@ -41,7 +41,7 @@ public class MyContext : ScenarioContext public class EndpointWithCustomCheck : EndpointConfigurationBuilder { - public EndpointWithCustomCheck() => EndpointSetup(c => c.ReportCustomChecksTo(Settings.DEFAULT_SERVICE_NAME, TimeSpan.FromSeconds(1))); + public EndpointWithCustomCheck() => EndpointSetup(c => c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1))); public class EventuallyFailingCustomCheck() : CustomCheck("EventuallyFailingCustomCheck", "Testing", TimeSpan.FromSeconds(1)) diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_email_notifications_are_enabled.cs b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_email_notifications_are_enabled.cs index 6bfa757a9d..24c3536ec5 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_email_notifications_are_enabled.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_email_notifications_are_enabled.cs @@ -84,7 +84,7 @@ public class MyContext : ScenarioContext public class EndpointWithFailingCustomCheck : EndpointConfigurationBuilder { - public EndpointWithFailingCustomCheck() => EndpointSetup(c => { c.ReportCustomChecksTo(Settings.DEFAULT_SERVICE_NAME, TimeSpan.FromSeconds(1)); }); + public EndpointWithFailingCustomCheck() => EndpointSetup(c => { c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); }); class FailingCustomCheck() : CustomCheck("MyCustomCheckId", "MyCategory") { diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_reporting_custom_check_with_signalr.cs b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_reporting_custom_check_with_signalr.cs index 63498ff12f..3fc74b63fe 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_reporting_custom_check_with_signalr.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/CustomChecks/When_reporting_custom_check_with_signalr.cs @@ -93,7 +93,7 @@ protected override Task OnStart(IMessageSession session, CancellationToken cance class EndpointWithCustomCheck : EndpointConfigurationBuilder { - public EndpointWithCustomCheck() => EndpointSetup(c => { c.ReportCustomChecksTo(Settings.DEFAULT_SERVICE_NAME, TimeSpan.FromSeconds(1)); }); + public EndpointWithCustomCheck() => EndpointSetup(c => { c.ReportCustomChecksTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); }); public class EventuallyFailingCustomCheck() : CustomCheck("EventuallyFailingCustomCheck", "Testing", TimeSpan.FromSeconds(1)) diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_fails.cs b/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_fails.cs index 58aba1d122..7aa9dd2f03 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_fails.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_fails.cs @@ -69,10 +69,10 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_SERVICE_NAME); + routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_INSTANCE_NAME); }, publisherMetadata => { - publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); + publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class CustomCheckFailedHandler(MyContext testContext) : IHandleMessages diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_succeeds.cs b/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_succeeds.cs index 1914962cc7..2ce41a7576 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_succeeds.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_a_custom_check_succeeds.cs @@ -64,10 +64,10 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_SERVICE_NAME); + routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_INSTANCE_NAME); }, publisherMetadata => { - publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); + publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class CustomCheckSucceededHandler(MyContext testContext) : IHandleMessages diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_heartbeat_is_restored.cs b/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_heartbeat_is_restored.cs index 15e5eb96ed..99a3a67121 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_heartbeat_is_restored.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_heartbeat_is_restored.cs @@ -64,8 +64,8 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class FailureHandler(MyContext testContext) : IHandleMessages { diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_heartbeat_loss_is_detected.cs b/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_heartbeat_loss_is_detected.cs index d694eb10e4..bf64a86596 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_heartbeat_loss_is_detected.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/ExternalIntegration/When_heartbeat_loss_is_detected.cs @@ -66,8 +66,8 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class FailureHandler(MyContext testContext) : IHandleMessages { diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_is_removed.cs b/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_is_removed.cs index d9bca770f4..35a09d31cf 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_is_removed.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_is_removed.cs @@ -61,7 +61,7 @@ class Context : ScenarioContext; public class StartingEndpoint : EndpointConfigurationBuilder { - public StartingEndpoint() => EndpointSetup(c => c.SendHeartbeatTo(Settings.DEFAULT_SERVICE_NAME, TimeSpan.FromHours(1))); + public StartingEndpoint() => EndpointSetup(c => c.SendHeartbeatTo(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromHours(1))); } } } \ No newline at end of file diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_starts_up.cs b/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_starts_up.cs index a400e2b47f..5f45e623df 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_starts_up.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_starts_up.cs @@ -42,7 +42,7 @@ public class StartingEndpoint : EndpointConfigurationBuilder public StartingEndpoint() => EndpointSetup(c => { - c.SendHeartbeatTo(Settings.DEFAULT_SERVICE_NAME); + c.SendHeartbeatTo(Settings.DEFAULT_INSTANCE_NAME); c.GetSettings().Set("ServiceControl.CustomHostIdentifier", hostIdentifier); c.UniquelyIdentifyRunningInstance().UsingCustomIdentifier(hostIdentifier); diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_with_heartbeat_plugin_starts_up.cs b/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_with_heartbeat_plugin_starts_up.cs index 74b4343416..13285fdbd1 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_with_heartbeat_plugin_starts_up.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/When_an_endpoint_with_heartbeat_plugin_starts_up.cs @@ -58,7 +58,7 @@ public class MyContext : ScenarioContext; public class StartingEndpoint : EndpointConfigurationBuilder { - public StartingEndpoint() => EndpointSetup(c => c.SendHeartbeatTo(Settings.DEFAULT_SERVICE_NAME)); + public StartingEndpoint() => EndpointSetup(c => c.SendHeartbeatTo(Settings.DEFAULT_INSTANCE_NAME)); } } } \ No newline at end of file diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/When_an_unmonitored_endpoint_is_marked_as_monitored.cs b/src/ServiceControl.AcceptanceTests/Monitoring/When_an_unmonitored_endpoint_is_marked_as_monitored.cs index ace5490f88..2ff666dc55 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/When_an_unmonitored_endpoint_is_marked_as_monitored.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/When_an_unmonitored_endpoint_is_marked_as_monitored.cs @@ -33,7 +33,7 @@ await Define() var options = new SendOptions(); options.DoNotEnforceBestPractices(); - options.SetDestination(Settings.DEFAULT_SERVICE_NAME); + options.SetDestination(Settings.DEFAULT_INSTANCE_NAME); return bus.Send(new NewEndpointDetected { diff --git a/src/ServiceControl.AcceptanceTests/Monitoring/When_unmonitored_endpoint_starts_to_sends_heartbeats.cs b/src/ServiceControl.AcceptanceTests/Monitoring/When_unmonitored_endpoint_starts_to_sends_heartbeats.cs index 708c059931..4310656b36 100644 --- a/src/ServiceControl.AcceptanceTests/Monitoring/When_unmonitored_endpoint_starts_to_sends_heartbeats.cs +++ b/src/ServiceControl.AcceptanceTests/Monitoring/When_unmonitored_endpoint_starts_to_sends_heartbeats.cs @@ -29,7 +29,7 @@ await Define() var options = new SendOptions(); options.DoNotEnforceBestPractices(); - options.SetDestination(Settings.DEFAULT_SERVICE_NAME); + options.SetDestination(Settings.DEFAULT_INSTANCE_NAME); return bus.Send(new NewEndpointDetected { @@ -81,7 +81,7 @@ public class WithoutHeartbeat : EndpointConfigurationBuilder public class WithHeartbeat : EndpointConfigurationBuilder { - public WithHeartbeat() => EndpointSetup(c => { c.SendHeartbeatTo(Settings.DEFAULT_SERVICE_NAME); }).CustomEndpointName(EndpointName); + public WithHeartbeat() => EndpointSetup(c => { c.SendHeartbeatTo(Settings.DEFAULT_INSTANCE_NAME); }).CustomEndpointName(EndpointName); } } } \ No newline at end of file diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_archived.cs b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_archived.cs index 01f9e3d078..1afc08e4c5 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_archived.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_archived.cs @@ -60,8 +60,8 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(FailedMessagesArchived).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(FailedMessagesArchived).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class FailureHandler(Context testContext) : IHandleMessages { diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_resolved_by_retry.cs b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_resolved_by_retry.cs index 35dfdedccd..c3fa1f3445 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_resolved_by_retry.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_resolved_by_retry.cs @@ -58,8 +58,8 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(FailedMessagesArchived).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(FailedMessagesArchived).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class FailureHandler(Context testContext) : IHandleMessages { diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_resolved_manually.cs b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_resolved_manually.cs index 08107ef521..cae477efa6 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_resolved_manually.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_resolved_manually.cs @@ -69,8 +69,8 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(MessageFailureResolvedManually).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(MessageFailureResolvedManually).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class FailureHandler(Context testContext) : IHandleMessages { diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_unarchived.cs b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_unarchived.cs index 2c14867ee5..8352573d79 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_unarchived.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_failed_message_is_unarchived.cs @@ -77,8 +77,8 @@ public ExternalProcessor() EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(FailedMessagesUnArchived).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(FailedMessagesUnArchived).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); } public class FailureHandler(Context testContext) : IHandleMessages diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_group_is_archived.cs b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_group_is_archived.cs index e12fcc571a..262f10e885 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_group_is_archived.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_group_is_archived.cs @@ -75,8 +75,8 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(FailedMessagesArchived).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(FailedMessagesArchived).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class FailureHandler(Context testContext) : IHandleMessages { diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_message_has_failed_detected.cs b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_message_has_failed_detected.cs index 3d93b91a96..0929239ed8 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_message_has_failed_detected.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_a_message_has_failed_detected.cs @@ -72,8 +72,8 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class FailureHandler(MyContext testContext) : IHandleMessages { diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_encountered_an_error.cs b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_encountered_an_error.cs index ff8f911b2a..f55edb9104 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_encountered_an_error.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/ExternalIntegration/When_encountered_an_error.cs @@ -97,8 +97,8 @@ public ExternalProcessor() => EndpointSetup(c => { var routing = c.ConfigureRouting(); - routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_SERVICE_NAME); - }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_SERVICE_NAME); }); + routing.RouteToEndpoint(typeof(MessageFailed).Assembly, Settings.DEFAULT_INSTANCE_NAME); + }, publisherMetadata => { publisherMetadata.RegisterPublisherFor(Settings.DEFAULT_INSTANCE_NAME); }); public class FailureHandler(MyContext testContext) : IHandleMessages { diff --git a/src/ServiceControl.AcceptanceTests/RootControllerTests.cs b/src/ServiceControl.AcceptanceTests/RootControllerTests.cs index c7eef9b139..3db994b942 100644 --- a/src/ServiceControl.AcceptanceTests/RootControllerTests.cs +++ b/src/ServiceControl.AcceptanceTests/RootControllerTests.cs @@ -24,7 +24,7 @@ public async Task Should_gather_remote_data() new RemoteInstanceSetting(settings.RootUrl), new RemoteInstanceSetting(settings.RootUrl) ]; - serviceName = settings.ServiceName; + serviceName = settings.InstanceName; baseAddress = settings.RootUrl; }; diff --git a/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs b/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs index 6f29290629..8862856c1e 100644 --- a/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs +++ b/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs @@ -70,7 +70,7 @@ public async Task Teardown() } #pragma warning disable IDE0060 // Remove unused parameter - protected void ExecuteWhen(Func execute, Func action, string instanceName = Settings.DEFAULT_SERVICE_NAME) + protected void ExecuteWhen(Func execute, Func action, string instanceName = Settings.DEFAULT_INSTANCE_NAME) #pragma warning restore IDE0060 // Remove unused parameter { var timeout = TimeSpan.FromSeconds(1); diff --git a/src/ServiceControl.AcceptanceTests/TestSupport/ReportSuccessfulRetryToServiceControl.cs b/src/ServiceControl.AcceptanceTests/TestSupport/ReportSuccessfulRetryToServiceControl.cs index 2f105fc85b..dd2cd5603a 100644 --- a/src/ServiceControl.AcceptanceTests/TestSupport/ReportSuccessfulRetryToServiceControl.cs +++ b/src/ServiceControl.AcceptanceTests/TestSupport/ReportSuccessfulRetryToServiceControl.cs @@ -16,7 +16,7 @@ public async Task Invoke(IIncomingPhysicalMessageContext context, Func setSettings; readonly Action customConfiguration; readonly Action hostBuilderCustomization; - readonly string instanceName = Settings.DEFAULT_SERVICE_NAME; + readonly string instanceName = Settings.DEFAULT_INSTANCE_NAME; } } \ No newline at end of file diff --git a/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs index 9fc860d8d6..35990ee062 100644 --- a/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs +++ b/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs @@ -45,8 +45,9 @@ async Task InitializeServiceControl(ScenarioContext context) var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace, defaultLevel: NLog.LogLevel.Debug, logPath: logPath); - settings = new Settings(instanceName, transportToUse.TypeName, persistenceToUse.PersistenceType, loggingSettings) + settings = new Settings(transportToUse.TypeName, persistenceToUse.PersistenceType, loggingSettings) { + InstanceName = instanceName, TransportConnectionString = transportToUse.ConnectionString, MaximumConcurrencyLevel = 2, ServiceControlQueueAddress = "SHOULDNOTBEUSED", @@ -118,9 +119,9 @@ async Task InitializeServiceControl(ScenarioContext context) { var logitem = new ScenarioContext.LogItem { - Endpoint = settings.ServiceName, + Endpoint = settings.InstanceName, Level = NServiceBus.Logging.LogLevel.Fatal, - LoggerName = $"{settings.ServiceName}.CriticalError", + LoggerName = $"{settings.InstanceName}.CriticalError", Message = $"{criticalErrorContext.Error}{Environment.NewLine}{criticalErrorContext.Exception}" }; context.Logs.Enqueue(logitem); @@ -152,7 +153,7 @@ public override async Task Stop(CancellationToken cancellationToken = default) } } - string instanceName = Settings.DEFAULT_SERVICE_NAME; + string instanceName = Settings.DEFAULT_INSTANCE_NAME; WebApplication host; Settings settings; } diff --git a/src/ServiceControl.Audit.UnitTests/API/APIApprovals.cs b/src/ServiceControl.Audit.UnitTests/API/APIApprovals.cs index c28f6809d7..5dd12b59de 100644 --- a/src/ServiceControl.Audit.UnitTests/API/APIApprovals.cs +++ b/src/ServiceControl.Audit.UnitTests/API/APIApprovals.cs @@ -128,10 +128,6 @@ public void PlatformSampleSettings() Approver.Verify(settings); } - static Settings CreateTestSettings() => - new( - Settings.DEFAULT_SERVICE_NAME, - "LearningTransport", - "InMemory"); + static Settings CreateTestSettings() => new("LearningTransport", "InMemory"); } } \ No newline at end of file diff --git a/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt b/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt index 8ef91f5b5d..652ae9f354 100644 --- a/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt +++ b/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt @@ -8,7 +8,6 @@ }, "MessageFilter": null, "ValidateConfiguration": true, - "SkipQueueCreation": false, "RootUrl": "http://localhost:8888/", "ApiUrl": "http://localhost:8888/api", "Port": 8888, @@ -23,7 +22,7 @@ "AuditLogQueue": "audit.log", "AuditRetentionPeriod": "30.00:00:00", "MaxBodySizeToStore": 102400, - "ServiceName": "Particular.ServiceControl.Audit", + "InstanceName": "Particular.ServiceControl.Audit", "TransportConnectionString": null, "MaximumConcurrencyLevel": 32, "ServiceControlQueueAddress": "Particular.ServiceControl", diff --git a/src/ServiceControl.Audit.UnitTests/Infrastructure/When_instance_is_setup.cs b/src/ServiceControl.Audit.UnitTests/Infrastructure/When_instance_is_setup.cs index 1e4f629410..c533bae0d8 100644 --- a/src/ServiceControl.Audit.UnitTests/Infrastructure/When_instance_is_setup.cs +++ b/src/ServiceControl.Audit.UnitTests/Infrastructure/When_instance_is_setup.cs @@ -34,8 +34,9 @@ public async Task Should_provision_queues() var instanceInputQueueName = "SomeInstanceQueue"; - var settings = new Settings(instanceInputQueueName, "FakeTransport", "InMemory") + var settings = new Settings("FakeTransport", "InMemory") { + InstanceName = instanceInputQueueName, ForwardAuditMessages = true, AssemblyLoadContextResolver = static _ => AssemblyLoadContext.Default }; diff --git a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/CommandRunner.cs b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/CommandRunner.cs index e4beac275b..bff386d02e 100644 --- a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/CommandRunner.cs +++ b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/CommandRunner.cs @@ -1,19 +1,15 @@ namespace ServiceControl.Audit.Infrastructure.Hosting.Commands { using System; - using System.Collections.Generic; using System.Threading.Tasks; using ServiceControl.Audit.Infrastructure.Settings; - class CommandRunner(List commands) + class CommandRunner(Type commandType) { public async Task Execute(HostArguments args, Settings settings) { - foreach (var commandType in commands) - { - var command = (AbstractCommand)Activator.CreateInstance(commandType); - await command.Execute(args, settings); - } + var command = (AbstractCommand)Activator.CreateInstance(commandType); + await command.Execute(args, settings); } } } \ No newline at end of file diff --git a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/ImportFailedAuditsCommand.cs b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/ImportFailedAuditsCommand.cs index c56f5caad3..a3ef6d289e 100644 --- a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/ImportFailedAuditsCommand.cs +++ b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/ImportFailedAuditsCommand.cs @@ -15,7 +15,7 @@ public override async Task Execute(HostArguments args, Settings settings) { settings.IngestAuditMessages = false; - var endpointConfiguration = new EndpointConfiguration(settings.ServiceName); + var endpointConfiguration = new EndpointConfiguration(settings.InstanceName); using var tokenSource = new CancellationTokenSource(); diff --git a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/RunCommand.cs b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/RunCommand.cs index 1bcac6d8ea..e769a4863b 100644 --- a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/RunCommand.cs +++ b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/RunCommand.cs @@ -10,7 +10,7 @@ class RunCommand : AbstractCommand { public override async Task Execute(HostArguments args, Settings settings) { - var endpointConfiguration = new EndpointConfiguration(settings.ServiceName); + var endpointConfiguration = new EndpointConfiguration(settings.InstanceName); var assemblyScanner = endpointConfiguration.AssemblyScanner(); assemblyScanner.ExcludeAssemblies("ServiceControl.Plugin"); diff --git a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/SetupCommand.cs b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/SetupCommand.cs index 454459115c..2f03b767a8 100644 --- a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/SetupCommand.cs +++ b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/SetupCommand.cs @@ -12,11 +12,9 @@ class SetupCommand : AbstractCommand { public override async Task Execute(HostArguments args, Settings settings) { - settings.SkipQueueCreation = args.SkipQueueCreation; - if (settings.IngestAuditMessages) { - if (settings.SkipQueueCreation) + if (args.SkipQueueCreation) { Logger.Info("Skipping queue creation"); } diff --git a/src/ServiceControl.Audit/Infrastructure/Hosting/Help.txt b/src/ServiceControl.Audit/Infrastructure/Hosting/Help.txt index 4d341974b9..30fad00314 100644 --- a/src/ServiceControl.Audit/Infrastructure/Hosting/Help.txt +++ b/src/ServiceControl.Audit/Infrastructure/Hosting/Help.txt @@ -1,17 +1,17 @@ ServiceControl by Particular Software USAGE: - ServiceControl.exe --maintenance + ServiceControl.exe --maintenance -MAINTENANCE +MAINTENANCE -The maintenance switch allows RavenDB Maintenance tasks to be carried out. In this mode ServiceControl enables the RavenDB Web UI only. +The maintenance switch allows RavenDB Maintenance tasks to be carried out. In this mode ServiceControl enables the RavenDB Web UI only. The REST API, message importers and the background document expiry are all disabled. -This mode is only supported when run interactively. +This mode is only supported when run interactively. SERVICE INSTALL AND UNINSTALL AND CONFIGURATION OPTIONS -As of Service Control 1.7 the command line uninstall and install switches have been removed. +As of Service Control 1.7 the command line uninstall and install switches have been removed. Please use the ServiceControl Management Utilities for adding and removing ServiceControl instances. diff --git a/src/ServiceControl.Audit/Infrastructure/Hosting/HostArguments.cs b/src/ServiceControl.Audit/Infrastructure/Hosting/HostArguments.cs index cbb67d4841..5221dcdc0a 100644 --- a/src/ServiceControl.Audit/Infrastructure/Hosting/HostArguments.cs +++ b/src/ServiceControl.Audit/Infrastructure/Hosting/HostArguments.cs @@ -1,7 +1,6 @@ namespace ServiceControl.Audit.Infrastructure.Hosting { using System; - using System.Collections.Generic; using System.IO; using System.Reflection; using Commands; @@ -17,30 +16,17 @@ public HostArguments(string[] args) args = [.. args, "-m"]; } - var executionMode = ExecutionMode.Run; - Commands = [typeof(RunCommand)]; - ServiceName = Settings.DEFAULT_SERVICE_NAME; - var defaultOptions = new OptionSet { - { - "?|h|help", "Help about the command line options.", key => { Help = true; } - } + { "?|h|help", "Help about the command line options.", key => Help = true } }; var maintenanceOptions = new OptionSet { { "m|maint|maintenance", - @"Run RavenDB only - use for DB maintenance", - s => - { - Commands = - [ - typeof(MaintenanceModeCommand) - ]; - executionMode = ExecutionMode.Maintenance; - } + "Run RavenDB only - use for DB maintenance", + s => Command = typeof(MaintenanceModeCommand) } }; @@ -48,24 +34,13 @@ public HostArguments(string[] args) { { "s|setup", - @"Internal use - for new installer", s => - { - Commands = [typeof(SetupCommand)]; - executionMode = ExecutionMode.RunInstallers; - } - }, - { - "serviceName=", - @"Specify the service name for the installed service.", s => { ServiceName = s; } - }, - { - "userName=", - @"Username for the account the service should run under.", s => { Username = s; } + "Internal use - for new installer", + s => Command = typeof(SetupCommand) }, { "skip-queue-creation", - @"Skip queue creation during install/update", - s => { SkipQueueCreation = true; } + "Skip queue creation during install/update", + s => SkipQueueCreation = true } }; @@ -74,30 +49,29 @@ public HostArguments(string[] args) { "import-failed-audits", "Import failed audit messages", - s => - { - Commands = [typeof(ImportFailedAuditsCommand)]; - executionMode = ExecutionMode.ImportFailedAudits; - } + s => Command = typeof(ImportFailedAuditsCommand) } }; try { externalInstallerOptions.Parse(args); - if (executionMode == ExecutionMode.RunInstallers) + + if (Command == typeof(SetupCommand)) { return; } maintenanceOptions.Parse(args); - if (executionMode == ExecutionMode.Maintenance) + + if (Command == typeof(MaintenanceModeCommand)) { return; } reimportFailedAuditsOptions.Parse(args); - if (executionMode == ExecutionMode.ImportFailedAudits) + + if (Command == typeof(ImportFailedAuditsCommand)) { return; } @@ -111,42 +85,24 @@ public HostArguments(string[] args) } } - public List Commands { get; private set; } - - public bool Help { get; set; } - - public string ServiceName { get; set; } + public Type Command { get; private set; } = typeof(RunCommand); - public string Username { get; set; } + public bool Help { get; private set; } - public bool SkipQueueCreation { get; set; } + public bool SkipQueueCreation { get; private set; } public void PrintUsage() { var helpText = string.Empty; - using ( - var stream = - Assembly.GetCallingAssembly() - .GetManifestResourceStream("ServiceControl.Audit.Infrastructure.Hosting.Help.txt")) + using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ServiceControl.Audit.Infrastructure.Hosting.Help.txt"); + + if (stream != null) { - if (stream != null) - { - using (var streamReader = new StreamReader(stream)) - { - helpText = streamReader.ReadToEnd(); - } - } + using var streamReader = new StreamReader(stream); + helpText = streamReader.ReadToEnd(); } Console.Out.WriteLine(helpText); } } - - enum ExecutionMode - { - RunInstallers, - Run, - ImportFailedAudits, - Maintenance - } } \ No newline at end of file diff --git a/src/ServiceControl.Audit/Infrastructure/NServiceBusFactory.cs b/src/ServiceControl.Audit/Infrastructure/NServiceBusFactory.cs index 839111fa1c..513ac8486f 100644 --- a/src/ServiceControl.Audit/Infrastructure/NServiceBusFactory.cs +++ b/src/ServiceControl.Audit/Infrastructure/NServiceBusFactory.cs @@ -18,7 +18,7 @@ public static void Configure(Settings.Settings settings, ITransportCustomization TransportSettings transportSettings, Func onCriticalError, EndpointConfiguration configuration) { - var endpointName = settings.ServiceName; + var endpointName = settings.InstanceName; if (configuration == null) { configuration = new EndpointConfiguration(endpointName); diff --git a/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs b/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs index c992c78582..be61d7b028 100644 --- a/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs +++ b/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs @@ -13,19 +13,15 @@ public class Settings { - public Settings(string serviceName = null, string transportType = null, string persisterType = null, LoggingSettings loggingSettings = null) + public Settings(string transportType = null, string persisterType = null, LoggingSettings loggingSettings = null) { LoggingSettings = loggingSettings ?? new(SettingsRootNamespace); - ServiceName = serviceName; + // Overwrite the instance name if it is specified in ENVVAR, reg, or config file -- LEGACY SETTING NAME + InstanceName = SettingsReader.Read(SettingsRootNamespace, "InternalQueueName", InstanceName); - if (string.IsNullOrEmpty(serviceName)) - { - ServiceName = DEFAULT_SERVICE_NAME; - } - - // Overwrite the service name if it is specified in ENVVAR, reg, or config file - ServiceName = SettingsReader.Read(SettingsRootNamespace, "InternalQueueName", ServiceName); + // Overwrite the instance name if it is specified in ENVVAR, reg, or config file + InstanceName = SettingsReader.Read(SettingsRootNamespace, "InstanceName", InstanceName); TransportType = transportType ?? SettingsReader.Read(SettingsRootNamespace, "TransportType"); @@ -93,8 +89,6 @@ void LoadAuditQueueInformation() public bool ValidateConfiguration => SettingsReader.Read(SettingsRootNamespace, "ValidateConfig", true); - public bool SkipQueueCreation { get; set; } - public string RootUrl { get @@ -147,7 +141,7 @@ public int MaxBodySizeToStore set => maxBodySizeToStore = value; } - public string ServiceName { get; } + public string InstanceName { get; init; } = DEFAULT_INSTANCE_NAME; public string TransportConnectionString { get; set; } public int MaximumConcurrencyLevel { get; set; } @@ -161,7 +155,7 @@ public TransportSettings ToTransportSettings() { var transportSettings = new TransportSettings { - EndpointName = ServiceName, + EndpointName = InstanceName, ConnectionString = TransportConnectionString, MaxConcurrency = MaximumConcurrencyLevel, TransportType = TransportType, @@ -283,7 +277,7 @@ static string Subscope(string address) int maxBodySizeToStore = SettingsReader.Read(SettingsRootNamespace, "MaxBodySizeToStore", MaxBodySizeToStoreDefault); - public const string DEFAULT_SERVICE_NAME = "Particular.ServiceControl.Audit"; + public const string DEFAULT_INSTANCE_NAME = "Particular.ServiceControl.Audit"; public static readonly SettingsRootNamespace SettingsRootNamespace = new("ServiceControl.Audit"); const int MaxBodySizeToStoreDefault = 102400; //100 kb diff --git a/src/ServiceControl.Audit/Infrastructure/WebApi/RootController.cs b/src/ServiceControl.Audit/Infrastructure/WebApi/RootController.cs index 767e187e00..42c53825d3 100644 --- a/src/ServiceControl.Audit/Infrastructure/WebApi/RootController.cs +++ b/src/ServiceControl.Audit/Infrastructure/WebApi/RootController.cs @@ -47,7 +47,7 @@ public OkObjectResult Config() { Host = new { - settings.ServiceName, + settings.InstanceName, Logging = new { settings.LoggingSettings.LogPath, diff --git a/src/ServiceControl.Audit/Program.cs b/src/ServiceControl.Audit/Program.cs index 4ae0274bbb..e478b2f991 100644 --- a/src/ServiceControl.Audit/Program.cs +++ b/src/ServiceControl.Audit/Program.cs @@ -22,6 +22,6 @@ var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace); LoggingConfigurator.ConfigureLogging(loggingSettings); -var settings = new Settings(arguments.ServiceName, loggingSettings: loggingSettings); +var settings = new Settings(loggingSettings: loggingSettings); -await new CommandRunner(arguments.Commands).Execute(arguments, settings); +await new CommandRunner(arguments.Command).Execute(arguments, settings); diff --git a/src/ServiceControl.Config/UI/InstanceAdd/MonitoringAddAttachment.cs b/src/ServiceControl.Config/UI/InstanceAdd/MonitoringAddAttachment.cs index d11b3feeac..384118f339 100644 --- a/src/ServiceControl.Config/UI/InstanceAdd/MonitoringAddAttachment.cs +++ b/src/ServiceControl.Config/UI/InstanceAdd/MonitoringAddAttachment.cs @@ -58,6 +58,7 @@ async Task Add() { DisplayName = viewModel.InstanceName, Name = viewModel.InstanceName.Replace(' ', '.'), + InstanceName = viewModel.InstanceName.Replace(' ', '.'), ServiceDescription = viewModel.Description, InstallPath = viewModel.DestinationPath, LogPath = viewModel.LogPath, diff --git a/src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddAttachment.cs b/src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddAttachment.cs index ab09dcca72..5e8eb5d97a 100644 --- a/src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddAttachment.cs +++ b/src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddAttachment.cs @@ -58,6 +58,7 @@ async Task Add() { serviceControlNewInstance.DisplayName = viewModel.ServiceControl.InstanceName; serviceControlNewInstance.Name = viewModel.ServiceControl.InstanceName.Replace(' ', '.'); + serviceControlNewInstance.InstanceName = viewModel.ServiceControl.InstanceName.Replace(' ', '.'); serviceControlNewInstance.ServiceDescription = viewModel.ServiceControl.Description; serviceControlNewInstance.DBPath = viewModel.ServiceControl.DatabasePath; serviceControlNewInstance.LogPath = viewModel.ServiceControl.LogPath; @@ -82,6 +83,7 @@ async Task Add() { auditNewInstance.DisplayName = viewModel.ServiceControlAudit.InstanceName; auditNewInstance.Name = viewModel.ServiceControlAudit.InstanceName.Replace(' ', '.'); + auditNewInstance.InstanceName = viewModel.ServiceControlAudit.InstanceName.Replace(' ', '.'); auditNewInstance.ServiceDescription = viewModel.ServiceControlAudit.Description; auditNewInstance.DBPath = viewModel.ServiceControlAudit.DatabasePath; auditNewInstance.LogPath = viewModel.ServiceControlAudit.LogPath; @@ -97,7 +99,7 @@ async Task Add() auditNewInstance.AuditRetentionPeriod = viewModel.ServiceControlAudit.AuditRetentionPeriod; auditNewInstance.ServiceAccount = viewModel.ServiceControlAudit.ServiceAccount; auditNewInstance.ServiceAccountPwd = viewModel.ServiceControlAudit.Password; - auditNewInstance.ServiceControlQueueAddress = serviceControlNewInstance == null ? string.Empty : serviceControlNewInstance.Name; + auditNewInstance.ServiceControlQueueAddress = serviceControlNewInstance == null ? string.Empty : serviceControlNewInstance.InstanceName; auditNewInstance.EnableFullTextSearchOnBodies = viewModel.ServiceControlAudit.EnableFullTextSearchOnBodies.Value; } diff --git a/src/ServiceControl.Config/UI/InstanceDetails/InstanceDetailsView.xaml b/src/ServiceControl.Config/UI/InstanceDetails/InstanceDetailsView.xaml index ef3b668589..46485b62c3 100644 --- a/src/ServiceControl.Config/UI/InstanceDetails/InstanceDetailsView.xaml +++ b/src/ServiceControl.Config/UI/InstanceDetails/InstanceDetailsView.xaml @@ -222,10 +222,10 @@ - + ServiceInstance.Name; + public string InstanceName => ServiceInstance.InstanceName; + public string Host { get diff --git a/src/ServiceControl.Management.PowerShell/Cmdlets/AuditInstances/NewServiceControlAuditInstance.cs b/src/ServiceControl.Management.PowerShell/Cmdlets/AuditInstances/NewServiceControlAuditInstance.cs index 14c63add08..c531667c82 100644 --- a/src/ServiceControl.Management.PowerShell/Cmdlets/AuditInstances/NewServiceControlAuditInstance.cs +++ b/src/ServiceControl.Management.PowerShell/Cmdlets/AuditInstances/NewServiceControlAuditInstance.cs @@ -145,6 +145,7 @@ protected override void ProcessRecord() newAuditInstance.LogPath = LogPath; newAuditInstance.DBPath = DBPath; newAuditInstance.Name = Name; + newAuditInstance.InstanceName = Name; newAuditInstance.DisplayName = string.IsNullOrWhiteSpace(DisplayName) ? Name : DisplayName; newAuditInstance.ServiceDescription = Description; newAuditInstance.ServiceAccount = ServiceAccount; diff --git a/src/ServiceControl.Management.PowerShell/Cmdlets/AuditInstances/PsAuditInstance.cs b/src/ServiceControl.Management.PowerShell/Cmdlets/AuditInstances/PsAuditInstance.cs index bbc05c8b34..2dd69b5d85 100644 --- a/src/ServiceControl.Management.PowerShell/Cmdlets/AuditInstances/PsAuditInstance.cs +++ b/src/ServiceControl.Management.PowerShell/Cmdlets/AuditInstances/PsAuditInstance.cs @@ -6,23 +6,34 @@ public class PsAuditInstance { - public string Name { get; set; } + public string ServiceName { get; set; } + + public string InstanceName { get; set; } + public string Url { get; set; } + public string HostName { get; set; } + public int Port { get; set; } + public int? DatabaseMaintenancePort { get; set; } public string InstallPath { get; set; } + public string DBPath { get; set; } + public string LogPath { get; set; } public string TransportPackageName { get; set; } + public string ConnectionString { get; set; } public string PersistencePackageName { get; set; } public string AuditQueue { get; set; } + public string AuditLogQueue { get; set; } + public bool ForwardAuditMessages { get; set; } public TimeSpan AuditRetentionPeriod { get; set; } @@ -38,7 +49,8 @@ public class PsAuditInstance public static PsAuditInstance FromInstance(ServiceControlAuditInstance instance) => new PsAuditInstance { - Name = instance.Name, + ServiceName = instance.Name, + InstanceName = instance.InstanceName, Url = instance.Url, HostName = instance.HostName, Port = instance.Port, diff --git a/src/ServiceControl.Management.PowerShell/Cmdlets/MonitoringInstances/NewMonitoringInstance.cs b/src/ServiceControl.Management.PowerShell/Cmdlets/MonitoringInstances/NewMonitoringInstance.cs index ba08aaab12..8f90c7e732 100644 --- a/src/ServiceControl.Management.PowerShell/Cmdlets/MonitoringInstances/NewMonitoringInstance.cs +++ b/src/ServiceControl.Management.PowerShell/Cmdlets/MonitoringInstances/NewMonitoringInstance.cs @@ -119,6 +119,7 @@ protected override void ProcessRecord() InstallPath = InstallPath, LogPath = LogPath, Name = Name, + InstanceName = Name, DisplayName = string.IsNullOrWhiteSpace(DisplayName) ? Name : DisplayName, ServiceDescription = Description, ServiceAccount = ServiceAccount, diff --git a/src/ServiceControl.Management.PowerShell/Cmdlets/MonitoringInstances/PsMonitoringService.cs b/src/ServiceControl.Management.PowerShell/Cmdlets/MonitoringInstances/PsMonitoringService.cs index 69665af96c..eb42509242 100644 --- a/src/ServiceControl.Management.PowerShell/Cmdlets/MonitoringInstances/PsMonitoringService.cs +++ b/src/ServiceControl.Management.PowerShell/Cmdlets/MonitoringInstances/PsMonitoringService.cs @@ -5,25 +5,36 @@ public class PsMonitoringService { - public string Name { get; set; } + public string ServiceName { get; set; } + + public string InstanceName { get; set; } + public string Url { get; set; } + public string HostName { get; set; } + public int Port { get; set; } public string InstallPath { get; set; } + public string LogPath { get; set; } public string TransportPackageName { get; set; } + public string ConnectionString { get; set; } + public string ErrorQueue { get; set; } + public string ServiceAccount { get; set; } + public SemanticVersion Version { get; set; } public static PsMonitoringService FromInstance(MonitoringInstance instance) { var result = new PsMonitoringService { - Name = instance.Name, + ServiceName = instance.Name, + InstanceName = instance.InstanceName, Url = instance.Url, HostName = instance.HostName, Port = instance.Port, diff --git a/src/ServiceControl.Management.PowerShell/Cmdlets/ServiceControlInstances/NewServiceControlInstance.cs b/src/ServiceControl.Management.PowerShell/Cmdlets/ServiceControlInstances/NewServiceControlInstance.cs index 2a9ca5c806..c7e2d6cfee 100644 --- a/src/ServiceControl.Management.PowerShell/Cmdlets/ServiceControlInstances/NewServiceControlInstance.cs +++ b/src/ServiceControl.Management.PowerShell/Cmdlets/ServiceControlInstances/NewServiceControlInstance.cs @@ -155,6 +155,7 @@ protected override void ProcessRecord() details.LogPath = LogPath; details.DBPath = DBPath; details.Name = Name; + details.InstanceName = Name; details.DisplayName = string.IsNullOrWhiteSpace(DisplayName) ? Name : DisplayName; details.ServiceDescription = Description; details.ServiceAccount = ServiceAccount; diff --git a/src/ServiceControl.Management.PowerShell/Cmdlets/ServiceControlInstances/PSServiceControl.cs b/src/ServiceControl.Management.PowerShell/Cmdlets/ServiceControlInstances/PSServiceControl.cs index 5a1274e099..11d5977c16 100644 --- a/src/ServiceControl.Management.PowerShell/Cmdlets/ServiceControlInstances/PSServiceControl.cs +++ b/src/ServiceControl.Management.PowerShell/Cmdlets/ServiceControlInstances/PSServiceControl.cs @@ -8,21 +8,32 @@ public class PsServiceControl { - public string Name { get; set; } + public string ServiceName { get; set; } + + public string InstanceName { get; set; } + public string Url { get; set; } + public string HostName { get; set; } + public int Port { get; set; } + public int? DatabaseMaintenancePort { get; set; } public string InstallPath { get; set; } + public string DBPath { get; set; } + public string LogPath { get; set; } public string TransportPackageName { get; set; } + public string ConnectionString { get; set; } public string ErrorQueue { get; set; } + public string ErrorLogQueue { get; set; } + public bool ForwardErrorMessages { get; set; } public TimeSpan ErrorRetentionPeriod { get; set; } @@ -47,7 +58,8 @@ public static PsServiceControl FromInstance(ServiceControlInstance instance) { var result = new PsServiceControl { - Name = instance.Name, + ServiceName = instance.Name, + InstanceName = instance.InstanceName, Url = instance.Url, HostName = instance.HostName, Port = instance.Port, diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs index ced2115f9d..2537e08268 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs +++ b/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs @@ -35,7 +35,6 @@ async Task InitializeServiceControl(ScenarioContext context) { settings = new Settings { - EndpointName = Settings.DEFAULT_ENDPOINT_NAME, TransportType = transportToUse.TypeName, ConnectionString = transportToUse.ConnectionString, HttpHostName = "localhost", @@ -72,18 +71,18 @@ async Task InitializeServiceControl(ScenarioContext context) setSettings(settings); - using (new DiagnosticTimer($"Creating infrastructure for {settings.EndpointName}")) + using (new DiagnosticTimer($"Creating infrastructure for {settings.InstanceName}")) { var setupCommand = new SetupCommand(); - await setupCommand.Execute(settings); + await setupCommand.Execute(new HostArguments([]), settings); } - var configuration = new EndpointConfiguration(settings.EndpointName); + var configuration = new EndpointConfiguration(settings.InstanceName); configuration.CustomizeServiceControlMonitoringEndpointTesting(context); customConfiguration(configuration); - using (new DiagnosticTimer($"Starting host for {settings.EndpointName}")) + using (new DiagnosticTimer($"Starting host for {settings.InstanceName}")) { var logPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(logPath); @@ -97,9 +96,9 @@ async Task InitializeServiceControl(ScenarioContext context) { var logitem = new ScenarioContext.LogItem { - Endpoint = settings.ServiceName, + Endpoint = settings.InstanceName, Level = LogLevel.Fatal, - LoggerName = $"{settings.ServiceName}.CriticalError", + LoggerName = $"{settings.InstanceName}.CriticalError", Message = $"{criticalErrorContext.Error}{Environment.NewLine}{criticalErrorContext.Exception}" }; context.Logs.Enqueue(logitem); @@ -113,13 +112,13 @@ async Task InitializeServiceControl(ScenarioContext context) host.UseServiceControlMonitoring(); await host.StartAsync(); - HttpClient = host.Services.GetRequiredKeyedService(settings.EndpointName).CreateClient(); + HttpClient = host.Services.GetRequiredKeyedService(settings.InstanceName).CreateClient(); } } public override async Task Stop(CancellationToken cancellationToken = default) { - using (new DiagnosticTimer($"Test TearDown for {settings.EndpointName}")) + using (new DiagnosticTimer($"Test TearDown for {settings.InstanceName}")) { await host.StopAsync(cancellationToken); HttpClient.Dispose(); diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/WebApplicationBuilderExtensions.cs b/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/WebApplicationBuilderExtensions.cs index 922531eee2..df576ef553 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/WebApplicationBuilderExtensions.cs +++ b/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/WebApplicationBuilderExtensions.cs @@ -14,7 +14,7 @@ public static void AddServiceControlMonitoringTesting(this WebApplicationBuilder hostBuilder.WebHost.UseTestServer(options => options.BaseAddress = new Uri(settings.RootUrl)); // This facilitates receiving the test server anywhere where DI is available - hostBuilder.Services.AddKeyedSingleton(settings.EndpointName, + hostBuilder.Services.AddKeyedSingleton(settings.InstanceName, (provider, _) => (TestServer)provider.GetRequiredService()); // // For acceptance testing purposes we are adding more controllers to the host diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_disconnected_count.cs b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_disconnected_count.cs index 9491833c0c..b42ba01e76 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_disconnected_count.cs +++ b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_disconnected_count.cs @@ -22,7 +22,7 @@ public async Task Should_report_via_http() await Define(ctx => context = ctx) .WithEndpoint(b => - b.CustomConfig(endpointConfig => endpointConfig.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_ENDPOINT_NAME, TimeSpan.FromMilliseconds(200), "First")) + b.CustomConfig(endpointConfig => endpointConfig.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromMilliseconds(200), "First")) .ToCreateInstance(endpointConfig => Endpoint.Create(endpointConfig), async (startableEndpoint, cancellationToken) => { context.FirstInstance = await startableEndpoint.Start(cancellationToken); @@ -30,7 +30,7 @@ await Define(ctx => context = ctx) return context.FirstInstance; })) .WithEndpoint(b => - b.CustomConfig(endpointConfig => endpointConfig.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_ENDPOINT_NAME, TimeSpan.FromMilliseconds(200), "Second")) + b.CustomConfig(endpointConfig => endpointConfig.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromMilliseconds(200), "Second")) .ToCreateInstance(endpointConfig => Endpoint.Create(endpointConfig), async (startableEndpoint, cancellationToken) => { context.SecondInstance = await startableEndpoint.Start(cancellationToken); diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_queue_length_data.cs b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_queue_length_data.cs index 65c1a1da41..f96d8f085f 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_queue_length_data.cs +++ b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_queue_length_data.cs @@ -33,7 +33,7 @@ await Define() ec.UniquelyIdentifyRunningInstance() .UsingCustomIdentifier(instanceId); ec.EnableMetrics() - .SendMetricDataToServiceControl(Settings.DEFAULT_ENDPOINT_NAME, TimeSpan.FromSeconds(1)); + .SendMetricDataToServiceControl(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); }); c.DoNotFailOnErrorMessages(); c.When(async s => @@ -50,7 +50,7 @@ await Define() { ec.MakeInstanceUniquelyAddressable("2"); ec.EnableMetrics() - .SendMetricDataToServiceControl(Settings.DEFAULT_ENDPOINT_NAME, + .SendMetricDataToServiceControl(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1), metricsInstanceId.ToString("N")); }); diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_retries_data.cs b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_retries_data.cs index c7007581e9..bab9d8aa9d 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_retries_data.cs +++ b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_retries_data.cs @@ -46,7 +46,7 @@ class EndpointWithRetries : EndpointConfigurationBuilder public EndpointWithRetries() => EndpointSetup(c => { - c.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_ENDPOINT_NAME, TimeSpan.FromSeconds(1)); + c.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); }); class Handler(TestContext testContext) : IHandleMessages diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_timings_data.cs b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_timings_data.cs index d60c8748d9..bf6717f4a5 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_timings_data.cs +++ b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_timings_data.cs @@ -37,7 +37,7 @@ class EndpointWithTimings : EndpointConfigurationBuilder public EndpointWithTimings() => EndpointSetup(c => { - c.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_ENDPOINT_NAME, TimeSpan.FromSeconds(1)); + c.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_INSTANCE_NAME, TimeSpan.FromSeconds(1)); }); class Handler : IHandleMessages diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/When_sending_legacy_metric_report.cs b/src/ServiceControl.Monitoring.AcceptanceTests/When_sending_legacy_metric_report.cs index 68c7340cf8..361c59f934 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/When_sending_legacy_metric_report.cs +++ b/src/ServiceControl.Monitoring.AcceptanceTests/When_sending_legacy_metric_report.cs @@ -19,7 +19,7 @@ await Define() b.When(session => { var sendOptions = new SendOptions(); - sendOptions.SetDestination(Settings.DEFAULT_ENDPOINT_NAME); + sendOptions.SetDestination(Settings.DEFAULT_INSTANCE_NAME); sendOptions.SetHeader(MetricHeaders.MetricInstanceId, "MetricInstanceId"); return session.Send(new MetricReport { Data = "{}" }, sendOptions); })) diff --git a/src/ServiceControl.Monitoring.UnitTests/ApprovalFiles/SettingsTests.PlatformSampleSettings.approved.txt b/src/ServiceControl.Monitoring.UnitTests/ApprovalFiles/SettingsTests.PlatformSampleSettings.approved.txt index bbfe4e7dd8..76f97964ff 100644 --- a/src/ServiceControl.Monitoring.UnitTests/ApprovalFiles/SettingsTests.PlatformSampleSettings.approved.txt +++ b/src/ServiceControl.Monitoring.UnitTests/ApprovalFiles/SettingsTests.PlatformSampleSettings.approved.txt @@ -1,5 +1,4 @@ { - "EndpointName": "Particular.Monitoring", "LoggingSettings": { "LogLevel": { "Name": "Info", @@ -7,16 +6,13 @@ }, "LogPath": "C:\\Logs" }, - "ServiceName": "Particular.Monitoring", + "InstanceName": "Particular.Monitoring", "TransportType": "NServiceBus.ServiceControlLearningTransport, ServiceControl.Transports.LearningTransport", "ConnectionString": null, "ErrorQueue": "error", - "Username": null, - "EnableInstallers": false, "HttpHostName": "localhost", "HttpPort": "9999", "EndpointUptimeGracePeriod": "00:00:40", - "SkipQueueCreation": false, "RootUrl": "http://localhost:9999/", "MaximumConcurrencyLevel": 32, "ServiceControlThroughputDataQueue": "ServiceControl.ThroughputData" diff --git a/src/ServiceControl.Monitoring/HostApplicationBuilderExtensions.cs b/src/ServiceControl.Monitoring/HostApplicationBuilderExtensions.cs index f6aee47def..59dbdf5992 100644 --- a/src/ServiceControl.Monitoring/HostApplicationBuilderExtensions.cs +++ b/src/ServiceControl.Monitoring/HostApplicationBuilderExtensions.cs @@ -83,12 +83,6 @@ static void ConfigureEndpoint(EndpointConfiguration config, Func(); } - - if (settings.EnableInstallers) - { - config.EnableInstallers(settings.Username); - } - config.DefineCriticalErrorAction(onCriticalError); config.GetSettings().Set(settings); diff --git a/src/ServiceControl.Monitoring/Hosting/Commands/AbstractCommand.cs b/src/ServiceControl.Monitoring/Hosting/Commands/AbstractCommand.cs index 12fba1e814..9dc057200f 100644 --- a/src/ServiceControl.Monitoring/Hosting/Commands/AbstractCommand.cs +++ b/src/ServiceControl.Monitoring/Hosting/Commands/AbstractCommand.cs @@ -4,6 +4,6 @@ abstract class AbstractCommand { - public abstract Task Execute(Settings settings); + public abstract Task Execute(HostArguments args, Settings settings); } } \ No newline at end of file diff --git a/src/ServiceControl.Monitoring/Hosting/Commands/CommandRunner.cs b/src/ServiceControl.Monitoring/Hosting/Commands/CommandRunner.cs index eda0e9f620..cf5a79c3d4 100644 --- a/src/ServiceControl.Monitoring/Hosting/Commands/CommandRunner.cs +++ b/src/ServiceControl.Monitoring/Hosting/Commands/CommandRunner.cs @@ -1,25 +1,14 @@ namespace ServiceControl.Monitoring { using System; - using System.Collections.Generic; using System.Threading.Tasks; - class CommandRunner + class CommandRunner(Type commandType) { - public CommandRunner(List commands) + public async Task Execute(HostArguments args, Settings settings) { - this.commands = commands; + var command = (AbstractCommand)Activator.CreateInstance(commandType); + await command.Execute(args, settings); } - - public async Task Execute(Settings settings) - { - foreach (var commandType in commands) - { - var command = (AbstractCommand)Activator.CreateInstance(commandType); - await command.Execute(settings); - } - } - - List commands; } } \ No newline at end of file diff --git a/src/ServiceControl.Monitoring/Hosting/Commands/RunCommand.cs b/src/ServiceControl.Monitoring/Hosting/Commands/RunCommand.cs index 9900f0eaaa..340c12fc08 100644 --- a/src/ServiceControl.Monitoring/Hosting/Commands/RunCommand.cs +++ b/src/ServiceControl.Monitoring/Hosting/Commands/RunCommand.cs @@ -8,9 +8,9 @@ namespace ServiceControl.Monitoring class RunCommand : AbstractCommand { - public override async Task Execute(Settings settings) + public override async Task Execute(HostArguments args, Settings settings) { - var endpointConfiguration = new EndpointConfiguration(settings.ServiceName); + var endpointConfiguration = new EndpointConfiguration(settings.InstanceName); var hostBuilder = WebApplication.CreateBuilder(); hostBuilder.AddServiceControlMonitoring((_, __) => Task.CompletedTask, settings, endpointConfiguration); diff --git a/src/ServiceControl.Monitoring/Hosting/Commands/SetupCommand.cs b/src/ServiceControl.Monitoring/Hosting/Commands/SetupCommand.cs index f883a6eece..3bd7830438 100644 --- a/src/ServiceControl.Monitoring/Hosting/Commands/SetupCommand.cs +++ b/src/ServiceControl.Monitoring/Hosting/Commands/SetupCommand.cs @@ -6,9 +6,9 @@ namespace ServiceControl.Monitoring class SetupCommand : AbstractCommand { - public override Task Execute(Settings settings) + public override Task Execute(HostArguments args, Settings settings) { - if (settings.SkipQueueCreation) + if (args.SkipQueueCreation) { Logger.Info("Skipping queue creation"); return Task.CompletedTask; diff --git a/src/ServiceControl.Monitoring/Hosting/HostArguments.cs b/src/ServiceControl.Monitoring/Hosting/HostArguments.cs index 3262cabd54..289649abfa 100644 --- a/src/ServiceControl.Monitoring/Hosting/HostArguments.cs +++ b/src/ServiceControl.Monitoring/Hosting/HostArguments.cs @@ -1,68 +1,30 @@ namespace ServiceControl.Monitoring { using System; - using System.Collections.Generic; class HostArguments { public HostArguments(string[] args) { - var executionMode = ExecutionMode.Run; - var setupOptions = new OptionSet { { "s|setup", "Install queues", - s => executionMode = ExecutionMode.Setup - }, - { - "serviceName=", - "Specify the service name for the installed service.", - s => overrides.Add(settings => { settings.ServiceName = s; }) - }, - { - "userName=", - "Username for the account the service should run under.", - s => overrides.Add(settings => settings.Username = s) + s => Command = typeof(SetupCommand) }, { "skip-queue-creation", "Skip queue creation during install/update", - s => overrides.Add(settings => settings.SkipQueueCreation = true) + s => SkipQueueCreation = true } }; setupOptions.Parse(args); - - switch (executionMode) - { - case ExecutionMode.Setup: - Commands.Add(typeof(SetupCommand)); - break; - case ExecutionMode.Run: - default: - Commands.Add(typeof(RunCommand)); - break; - } } - public List Commands { get; } = []; + public Type Command { get; private set; } = typeof(RunCommand); - public void ApplyOverridesTo(Settings settings) - { - foreach (var @override in overrides) - { - @override.Invoke(settings); - } - } - - IList> overrides = []; - - enum ExecutionMode - { - Run, - Setup - } + public bool SkipQueueCreation { get; private set; } } } \ No newline at end of file diff --git a/src/ServiceControl.Monitoring/Program.cs b/src/ServiceControl.Monitoring/Program.cs index 817409d821..f6b10140f5 100644 --- a/src/ServiceControl.Monitoring/Program.cs +++ b/src/ServiceControl.Monitoring/Program.cs @@ -14,7 +14,6 @@ var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace); LoggingConfigurator.ConfigureLogging(loggingSettings); -var settings = new Settings(loggingSettings); -arguments.ApplyOverridesTo(settings); +var settings = new Settings(loggingSettings: loggingSettings); -await new CommandRunner(arguments.Commands).Execute(settings); +await new CommandRunner(arguments.Command).Execute(arguments, settings); diff --git a/src/ServiceControl.Monitoring/Settings.cs b/src/ServiceControl.Monitoring/Settings.cs index d466730bf9..8084e43d55 100644 --- a/src/ServiceControl.Monitoring/Settings.cs +++ b/src/ServiceControl.Monitoring/Settings.cs @@ -16,6 +16,9 @@ public Settings(LoggingSettings loggingSettings = null) { LoggingSettings = loggingSettings ?? new(SettingsRootNamespace); + // Overwrite the instance name if it is specified in ENVVAR, reg, or config file + InstanceName = SettingsReader.Read(SettingsRootNamespace, "InstanceName", InstanceName); + TransportType = SettingsReader.Read(SettingsRootNamespace, "TransportType"); ConnectionString = GetConnectionString(); @@ -32,7 +35,7 @@ public Settings(LoggingSettings loggingSettings = null) HttpHostName = SettingsReader.Read(SettingsRootNamespace, "HttpHostname"); HttpPort = SettingsReader.Read(SettingsRootNamespace, "HttpPort"); } - EndpointName = SettingsReader.Read(SettingsRootNamespace, "EndpointName"); + EndpointUptimeGracePeriod = TimeSpan.Parse(SettingsReader.Read(SettingsRootNamespace, "EndpointUptimeGracePeriod", "00:00:40")); MaximumConcurrencyLevel = SettingsReader.Read(SettingsRootNamespace, "MaximumConcurrencyLevel", 32); ServiceControlThroughputDataQueue = SettingsReader.Read(SettingsRootNamespace, "ServiceControlThroughputDataQueue", "ServiceControl.ThroughputData"); @@ -40,18 +43,12 @@ public Settings(LoggingSettings loggingSettings = null) AssemblyLoadContextResolver = static assemblyPath => new PluginAssemblyLoadContext(assemblyPath); } - public string EndpointName - { - get => endpointName ?? ServiceName; - set => endpointName = value; - } - [JsonIgnore] public Func AssemblyLoadContextResolver { get; set; } public LoggingSettings LoggingSettings { get; } - public string ServiceName { get; set; } = DEFAULT_ENDPOINT_NAME; + public string InstanceName { get; init; } = DEFAULT_INSTANCE_NAME; public string TransportType { get; set; } @@ -59,18 +56,12 @@ public string EndpointName public string ErrorQueue { get; set; } - public string Username { get; set; } - - public bool EnableInstallers { get; set; } - public string HttpHostName { get; set; } public string HttpPort { get; set; } public TimeSpan EndpointUptimeGracePeriod { get; set; } - public bool SkipQueueCreation { get; set; } - public string RootUrl => $"http://{HttpHostName}:{HttpPort}/"; public int MaximumConcurrencyLevel { get; set; } @@ -82,7 +73,7 @@ public TransportSettings ToTransportSettings() var transportSettings = new TransportSettings { ConnectionString = ConnectionString, - EndpointName = EndpointName, + EndpointName = InstanceName, ErrorQueue = ErrorQueue, MaxConcurrency = MaximumConcurrencyLevel, AssemblyLoadContextResolver = AssemblyLoadContextResolver, @@ -103,11 +94,9 @@ static string GetConnectionString() return connectionStringSettings?.ConnectionString; } - string endpointName; - internal Func, byte[], Func, Task> OnMessage { get; set; } = (messageId, headers, body, next) => next(); - public const string DEFAULT_ENDPOINT_NAME = "Particular.Monitoring"; + public const string DEFAULT_INSTANCE_NAME = "Particular.Monitoring"; public static readonly SettingsRootNamespace SettingsRootNamespace = new("Monitoring"); } } \ No newline at end of file diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs index 0c3cf0fde7..f618503256 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs @@ -19,8 +19,8 @@ namespace ServiceControl.MultiInstance.AcceptanceTests [TestFixture] abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProviderMultiInstance { - protected static string ServiceControlInstanceName { get; } = Settings.DEFAULT_SERVICE_NAME; - protected static string ServiceControlAuditInstanceName { get; } = Audit.Infrastructure.Settings.Settings.DEFAULT_SERVICE_NAME; + protected static string ServiceControlInstanceName { get; } = Settings.DEFAULT_INSTANCE_NAME; + protected static string ServiceControlAuditInstanceName { get; } = Audit.Infrastructure.Settings.Settings.DEFAULT_INSTANCE_NAME; public Dictionary HttpClients => serviceControlRunnerBehavior.HttpClients; public Dictionary SerializerOptions => serviceControlRunnerBehavior.SerializerOptions; diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/HttpExtensionsMultiinstance.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/HttpExtensionsMultiinstance.cs index c4f7f7d430..d09497c90a 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/HttpExtensionsMultiinstance.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/HttpExtensionsMultiinstance.cs @@ -17,37 +17,37 @@ static IAcceptanceTestInfrastructureProvider ToHttpExtension(this IAcceptanceTes SerializerOptions = providerMultiInstance.SerializerOptions[instanceName], }; - public static Task Put(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, Func requestHasFailed = null, string instanceName = Settings.DEFAULT_SERVICE_NAME) where T : class + public static Task Put(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, Func requestHasFailed = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class { return providerMultiInstance.ToHttpExtension(instanceName).Put(url, payload, requestHasFailed); } - public static Task GetRaw(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, string instanceName = Settings.DEFAULT_SERVICE_NAME) + public static Task GetRaw(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, string instanceName = Settings.DEFAULT_INSTANCE_NAME) { return providerMultiInstance.ToHttpExtension(instanceName).GetRaw(url); } - public static Task> TryGetMany(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_SERVICE_NAME) where T : class + public static Task> TryGetMany(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class { return providerMultiInstance.ToHttpExtension(instanceName).TryGetMany(url, condition); } - public static Task Patch(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, string instanceName = Settings.DEFAULT_SERVICE_NAME) where T : class + public static Task Patch(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class { return providerMultiInstance.ToHttpExtension(instanceName).Patch(url, payload); } - public static Task> TryGet(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_SERVICE_NAME) where T : class + public static Task> TryGet(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class { return providerMultiInstance.ToHttpExtension(instanceName).TryGet(url, condition); } - public static Task> TryGetSingle(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_SERVICE_NAME) where T : class + public static Task> TryGetSingle(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, Predicate condition = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class { return providerMultiInstance.ToHttpExtension(instanceName).TryGetSingle(url, condition); } - public static Task Post(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, Func requestHasFailed = null, string instanceName = Settings.DEFAULT_SERVICE_NAME) where T : class + public static Task Post(this IAcceptanceTestInfrastructureProviderMultiInstance providerMultiInstance, string url, T payload = null, Func requestHasFailed = null, string instanceName = Settings.DEFAULT_INSTANCE_NAME) where T : class { return providerMultiInstance.ToHttpExtension(instanceName).Post(url, payload, requestHasFailed); } diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs index 54a7ec6964..231c462e66 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs @@ -60,9 +60,9 @@ public async Task Initialize(RunDescriptor run) transportToUse, new AcceptanceTestStorageConfiguration(), auditSettings => { - auditSettings.ServiceControlQueueAddress = PrimaryInstanceSettings.DEFAULT_SERVICE_NAME; + auditSettings.ServiceControlQueueAddress = PrimaryInstanceSettings.DEFAULT_INSTANCE_NAME; customServiceControlAuditSettings(auditSettings); - SettingsPerInstance[AuditInstanceSettings.DEFAULT_SERVICE_NAME] = auditSettings; + SettingsPerInstance[AuditInstanceSettings.DEFAULT_INSTANCE_NAME] = auditSettings; }, auditEndpointConfiguration => { var scanner = auditEndpointConfiguration.AssemblyScanner(); @@ -80,11 +80,11 @@ public async Task Initialize(RunDescriptor run) }, _ => { }, auditHostBuilder => auditHostBuilderCustomization(auditHostBuilder)); - typeof(ScenarioContext).GetProperty("CurrentEndpoint", BindingFlags.Static | BindingFlags.NonPublic)?.SetValue(run.ScenarioContext, AuditInstanceSettings.DEFAULT_SERVICE_NAME); + typeof(ScenarioContext).GetProperty("CurrentEndpoint", BindingFlags.Static | BindingFlags.NonPublic)?.SetValue(run.ScenarioContext, AuditInstanceSettings.DEFAULT_INSTANCE_NAME); await auditInstanceComponentRunner.Initialize(run); - HttpClients[AuditInstanceSettings.DEFAULT_SERVICE_NAME] = auditInstanceComponentRunner.HttpClient; - SerializerOptions[AuditInstanceSettings.DEFAULT_SERVICE_NAME] = auditInstanceComponentRunner.SerializerOptions; + HttpClients[AuditInstanceSettings.DEFAULT_INSTANCE_NAME] = auditInstanceComponentRunner.HttpClient; + SerializerOptions[AuditInstanceSettings.DEFAULT_INSTANCE_NAME] = auditInstanceComponentRunner.SerializerOptions; var auditInstance = new RemoteInstanceSetting(auditInstanceComponentRunner.InstanceTestServer.BaseAddress.ToString()); TestServerPerRemoteInstance[auditInstance.InstanceId] = auditInstanceComponentRunner.InstanceTestServer; @@ -94,7 +94,7 @@ public async Task Initialize(RunDescriptor run) { primarySettings.RemoteInstances = [auditInstance]; customServiceControlSettings(primarySettings); - SettingsPerInstance[PrimaryInstanceSettings.DEFAULT_SERVICE_NAME] = primarySettings; + SettingsPerInstance[PrimaryInstanceSettings.DEFAULT_INSTANCE_NAME] = primarySettings; }, primaryEndpointConfiguration => { @@ -118,7 +118,7 @@ public async Task Initialize(RunDescriptor run) // For example one way to deal with this is to have a custom invoker that figures out the right target based on the base address // in the request URI. primaryHostBuilder.Services.AddKeyedSingleton("Forwarding", () => auditInstanceComponentRunner.InstanceTestServer.CreateHandler()); - foreach (var remoteInstance in ((PrimaryInstanceSettings)SettingsPerInstance[PrimaryInstanceSettings.DEFAULT_SERVICE_NAME]).RemoteInstances) + foreach (var remoteInstance in ((PrimaryInstanceSettings)SettingsPerInstance[PrimaryInstanceSettings.DEFAULT_INSTANCE_NAME]).RemoteInstances) { if (TestServerPerRemoteInstance.TryGetValue(remoteInstance.InstanceId, out var testServer)) { @@ -132,11 +132,11 @@ public async Task Initialize(RunDescriptor run) primaryHostBuilderCustomization(primaryHostBuilder); }); - typeof(ScenarioContext).GetProperty("CurrentEndpoint", BindingFlags.Static | BindingFlags.NonPublic)?.SetValue(run.ScenarioContext, PrimaryInstanceSettings.DEFAULT_SERVICE_NAME); + typeof(ScenarioContext).GetProperty("CurrentEndpoint", BindingFlags.Static | BindingFlags.NonPublic)?.SetValue(run.ScenarioContext, PrimaryInstanceSettings.DEFAULT_INSTANCE_NAME); await primaryInstanceComponentRunner.Initialize(run); - HttpClients[PrimaryInstanceSettings.DEFAULT_SERVICE_NAME] = primaryInstanceComponentRunner.HttpClient; - SerializerOptions[PrimaryInstanceSettings.DEFAULT_SERVICE_NAME] = primaryInstanceComponentRunner.SerializerOptions; + HttpClients[PrimaryInstanceSettings.DEFAULT_INSTANCE_NAME] = primaryInstanceComponentRunner.HttpClient; + SerializerOptions[PrimaryInstanceSettings.DEFAULT_INSTANCE_NAME] = primaryInstanceComponentRunner.SerializerOptions; } public override async Task Stop(CancellationToken cancellationToken = default) diff --git a/src/ServiceControl.Persistence.Tests/RetryStateTests.cs b/src/ServiceControl.Persistence.Tests/RetryStateTests.cs index 56d47ef7a9..07334e2596 100644 --- a/src/ServiceControl.Persistence.Tests/RetryStateTests.cs +++ b/src/ServiceControl.Persistence.Tests/RetryStateTests.cs @@ -276,7 +276,7 @@ class FakeApplicationLifetime : IHostApplicationLifetime class TestReturnToSenderDequeuer : ReturnToSenderDequeuer { public TestReturnToSenderDequeuer(ReturnToSender returnToSender, IErrorMessageDataStore store, IDomainEvents domainEvents, string endpointName) - : base(returnToSender, store, domainEvents, null, null, new Settings(serviceName: endpointName)) + : base(returnToSender, store, domainEvents, null, null, new Settings { InstanceName = endpointName }) { } diff --git a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt b/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt index b13b3962d0..8e7a31e15e 100644 --- a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt +++ b/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.PlatformSampleSettings.approved.txt @@ -13,7 +13,6 @@ "ValidateConfiguration": true, "ExternalIntegrationsDispatchingBatchSize": 100, "DisableExternalIntegrationsPublishing": false, - "SkipQueueCreation": false, "RunCleanupBundle": false, "RootUrl": "http://localhost:8888/", "ApiUrl": "http://localhost:8888/api", @@ -35,7 +34,7 @@ "AuditRetentionPeriod": null, "ErrorRetentionPeriod": "10.00:00:00", "EventsRetentionPeriod": "14.00:00:00", - "ServiceName": "Particular.ServiceControl", + "InstanceName": "Particular.ServiceControl", "TransportConnectionString": null, "ProcessRetryBatchesFrequency": "00:00:30", "TimeToRestartErrorIngestionAfterFailure": "00:01:00", diff --git a/src/ServiceControl/CustomChecks/InternalCustomChecks/InternalCustomChecks.cs b/src/ServiceControl/CustomChecks/InternalCustomChecks/InternalCustomChecks.cs index 791b756b0d..eb64b4a317 100644 --- a/src/ServiceControl/CustomChecks/InternalCustomChecks/InternalCustomChecks.cs +++ b/src/ServiceControl/CustomChecks/InternalCustomChecks/InternalCustomChecks.cs @@ -22,7 +22,7 @@ public static IHostApplicationBuilder AddInternalCustomChecks(this IHostApplicat provider.GetRequiredService(), provider.GetRequiredService(), provider.GetRequiredService(), - provider.GetRequiredService().ServiceName)); + provider.GetRequiredService().InstanceName)); return hostBuilder; } } diff --git a/src/ServiceControl/Hosting/Commands/CommandRunner.cs b/src/ServiceControl/Hosting/Commands/CommandRunner.cs index 1d9a88692e..f959364f85 100644 --- a/src/ServiceControl/Hosting/Commands/CommandRunner.cs +++ b/src/ServiceControl/Hosting/Commands/CommandRunner.cs @@ -1,20 +1,16 @@ namespace ServiceControl.Hosting.Commands { using System; - using System.Collections.Generic; using System.Threading.Tasks; using Particular.ServiceControl.Hosting; using ServiceBus.Management.Infrastructure.Settings; - class CommandRunner(List commands) + class CommandRunner(Type commandType) { public async Task Execute(HostArguments args, Settings settings) { - foreach (var commandType in commands) - { - var command = (AbstractCommand)Activator.CreateInstance(commandType); - await command.Execute(args, settings); - } + var command = (AbstractCommand)Activator.CreateInstance(commandType); + await command.Execute(args, settings); } } } \ No newline at end of file diff --git a/src/ServiceControl/Hosting/Commands/ImportFailedErrorsCommand.cs b/src/ServiceControl/Hosting/Commands/ImportFailedErrorsCommand.cs index f79775db92..585711b497 100644 --- a/src/ServiceControl/Hosting/Commands/ImportFailedErrorsCommand.cs +++ b/src/ServiceControl/Hosting/Commands/ImportFailedErrorsCommand.cs @@ -50,7 +50,7 @@ public override async Task Execute(HostArguments args, Settings settings) protected virtual EndpointConfiguration CreateEndpointConfiguration(Settings settings) { - var endpointConfiguration = new EndpointConfiguration(settings.ServiceName); + var endpointConfiguration = new EndpointConfiguration(settings.InstanceName); var assemblyScanner = endpointConfiguration.AssemblyScanner(); assemblyScanner.ExcludeAssemblies("ServiceControl.Plugin"); diff --git a/src/ServiceControl/Hosting/Commands/RunCommand.cs b/src/ServiceControl/Hosting/Commands/RunCommand.cs index e53758a5dd..db658857de 100644 --- a/src/ServiceControl/Hosting/Commands/RunCommand.cs +++ b/src/ServiceControl/Hosting/Commands/RunCommand.cs @@ -13,7 +13,7 @@ class RunCommand : AbstractCommand { public override async Task Execute(HostArguments args, Settings settings) { - var endpointConfiguration = new EndpointConfiguration(settings.ServiceName); + var endpointConfiguration = new EndpointConfiguration(settings.InstanceName); var assemblyScanner = endpointConfiguration.AssemblyScanner(); assemblyScanner.ExcludeAssemblies("ServiceControl.Plugin"); diff --git a/src/ServiceControl/Hosting/Commands/SetupCommand.cs b/src/ServiceControl/Hosting/Commands/SetupCommand.cs index c43240b83a..41ef355fd4 100644 --- a/src/ServiceControl/Hosting/Commands/SetupCommand.cs +++ b/src/ServiceControl/Hosting/Commands/SetupCommand.cs @@ -14,8 +14,6 @@ class SetupCommand : AbstractCommand { public override async Task Execute(HostArguments args, Settings settings) { - settings.SkipQueueCreation = args.SkipQueueCreation; - var hostBuilder = Host.CreateApplicationBuilder(); hostBuilder.AddServiceControlInstallers(settings); @@ -35,7 +33,7 @@ public override async Task Execute(HostArguments args, Settings settings) await host.StartAsync(); - if (settings.SkipQueueCreation) + if (args.SkipQueueCreation) { Logger.Info("Skipping queue creation"); } diff --git a/src/ServiceControl/Hosting/Help.txt b/src/ServiceControl/Hosting/Help.txt index 4d341974b9..30fad00314 100644 --- a/src/ServiceControl/Hosting/Help.txt +++ b/src/ServiceControl/Hosting/Help.txt @@ -1,17 +1,17 @@ ServiceControl by Particular Software USAGE: - ServiceControl.exe --maintenance + ServiceControl.exe --maintenance -MAINTENANCE +MAINTENANCE -The maintenance switch allows RavenDB Maintenance tasks to be carried out. In this mode ServiceControl enables the RavenDB Web UI only. +The maintenance switch allows RavenDB Maintenance tasks to be carried out. In this mode ServiceControl enables the RavenDB Web UI only. The REST API, message importers and the background document expiry are all disabled. -This mode is only supported when run interactively. +This mode is only supported when run interactively. SERVICE INSTALL AND UNINSTALL AND CONFIGURATION OPTIONS -As of Service Control 1.7 the command line uninstall and install switches have been removed. +As of Service Control 1.7 the command line uninstall and install switches have been removed. Please use the ServiceControl Management Utilities for adding and removing ServiceControl instances. diff --git a/src/ServiceControl/Hosting/HostArguments.cs b/src/ServiceControl/Hosting/HostArguments.cs index 1a0e243c48..f2151d8968 100644 --- a/src/ServiceControl/Hosting/HostArguments.cs +++ b/src/ServiceControl/Hosting/HostArguments.cs @@ -1,7 +1,6 @@ namespace Particular.ServiceControl.Hosting { using System; - using System.Collections.Generic; using System.IO; using System.Reflection; using global::ServiceControl.Configuration; @@ -17,30 +16,17 @@ public HostArguments(string[] args) args = [.. args, "-m"]; } - var executionMode = ExecutionMode.Run; - Commands = [typeof(RunCommand)]; - ServiceName = Settings.DEFAULT_SERVICE_NAME; - var defaultOptions = new OptionSet { - { - "?|h|help", "Help about the command line options.", key => { Help = true; } - } + { "?|h|help", "Help about the command line options.", key => Help = true } }; var maintenanceOptions = new OptionSet { { "m|maint|maintenance", - @"Run RavenDB only - use for DB maintenance", - s => - { - Commands = - [ - typeof(MaintenanceModeCommand) - ]; - executionMode = ExecutionMode.Maintenance; - } + "Run RavenDB only - use for DB maintenance", + s => Command = typeof(MaintenanceModeCommand) } }; @@ -48,24 +34,13 @@ public HostArguments(string[] args) { { "s|setup", - @"Internal use - for new installer", s => - { - Commands = [typeof(SetupCommand)]; - executionMode = ExecutionMode.RunInstallers; - } - }, - { - "serviceName=", - @"Specify the service name for the installed service.", s => { ServiceName = s; } - }, - { - "userName=", - @"Username for the account the service should run under.", s => { Username = s; } + "Internal use - for new installer", + s => Command = typeof(SetupCommand) }, { "skip-queue-creation", - @"Skip queue creation during install/update", - s => { SkipQueueCreation = true; } + "Skip queue creation during install/update", + s => SkipQueueCreation = true } }; @@ -74,30 +49,29 @@ public HostArguments(string[] args) { "import-failed-errors", "Import failed error messages", - s => - { - Commands = [typeof(ImportFailedErrorsCommand)]; - executionMode = ExecutionMode.ImportFailedErrors; - } + s => Command = typeof(ImportFailedErrorsCommand) } }; try { externalInstallerOptions.Parse(args); - if (executionMode == ExecutionMode.RunInstallers) + + if (Command == typeof(SetupCommand)) { return; } maintenanceOptions.Parse(args); - if (executionMode == ExecutionMode.Maintenance) + + if (Command == typeof(MaintenanceModeCommand)) { return; } reimportFailedErrorsOptions.Parse(args); - if (executionMode == ExecutionMode.ImportFailedErrors) + + if (Command == typeof(ImportFailedErrorsCommand)) { return; } @@ -111,42 +85,25 @@ public HostArguments(string[] args) } } - public List Commands { get; private set; } + public Type Command { get; private set; } = typeof(RunCommand); - public bool Help { get; set; } + public bool Help { get; private set; } - public string ServiceName { get; set; } - - public string Username { get; set; } - - public bool SkipQueueCreation { get; set; } + public bool SkipQueueCreation { get; private set; } public void PrintUsage() { var helpText = string.Empty; - using ( - var stream = - Assembly.GetCallingAssembly() - .GetManifestResourceStream("ServiceControl.Hosting.Help.txt")) + + using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ServiceControl.Hosting.Help.txt"); + + if (stream != null) { - if (stream != null) - { - using (var streamReader = new StreamReader(stream)) - { - helpText = streamReader.ReadToEnd(); - } - } + using var streamReader = new StreamReader(stream); + helpText = streamReader.ReadToEnd(); } Console.Out.WriteLine(helpText); } } - - enum ExecutionMode - { - RunInstallers, - Run, - Maintenance, - ImportFailedErrors - } } \ No newline at end of file diff --git a/src/ServiceControl/HostingComponent.cs b/src/ServiceControl/HostingComponent.cs index 49ead61398..df5d818048 100644 --- a/src/ServiceControl/HostingComponent.cs +++ b/src/ServiceControl/HostingComponent.cs @@ -16,6 +16,6 @@ public override void Configure(Settings settings, ITransportCustomization transp services.AddSingleton(); } - public override void Setup(Settings settings, IComponentInstallationContext context, IHostApplicationBuilder hostBuilder) => context.CreateQueue(settings.ServiceName); + public override void Setup(Settings settings, IComponentInstallationContext context, IHostApplicationBuilder hostBuilder) => context.CreateQueue(settings.InstanceName); } } \ No newline at end of file diff --git a/src/ServiceControl/Infrastructure/Api/ConfigurationApi.cs b/src/ServiceControl/Infrastructure/Api/ConfigurationApi.cs index 0ce4821349..da665f801f 100644 --- a/src/ServiceControl/Infrastructure/Api/ConfigurationApi.cs +++ b/src/ServiceControl/Infrastructure/Api/ConfigurationApi.cs @@ -55,7 +55,7 @@ public Task GetConfig(CancellationToken cancellationToken) { Host = new { - settings.ServiceName, + settings.InstanceName, Logging = new { settings.LoggingSettings.LogPath, diff --git a/src/ServiceControl/Infrastructure/Settings/Settings.cs b/src/ServiceControl/Infrastructure/Settings/Settings.cs index 38e4d9c15f..b223b10bdc 100644 --- a/src/ServiceControl/Infrastructure/Settings/Settings.cs +++ b/src/ServiceControl/Infrastructure/Settings/Settings.cs @@ -20,7 +20,6 @@ namespace ServiceBus.Management.Infrastructure.Settings public class Settings { public Settings( - string serviceName = null, string transportType = null, string persisterType = null, LoggingSettings loggingSettings = null, @@ -30,15 +29,11 @@ public Settings( { LoggingSettings = loggingSettings ?? new(SettingsRootNamespace); - ServiceName = serviceName; + // Overwrite the instance name if it is specified in ENVVAR, reg, or config file -- LEGACY SETTING NAME + InstanceName = SettingsReader.Read(SettingsRootNamespace, "InternalQueueName", InstanceName); - if (string.IsNullOrEmpty(serviceName)) - { - ServiceName = DEFAULT_SERVICE_NAME; - } - - // Overwrite the service name if it is specified in ENVVAR, reg, or config file - ServiceName = SettingsReader.Read(SettingsRootNamespace, "InternalQueueName", ServiceName); + // Overwrite the instance name if it is specified in ENVVAR, reg, or config file + InstanceName = SettingsReader.Read(SettingsRootNamespace, "InstanceName", InstanceName); LoadErrorIngestionSettings(); @@ -94,8 +89,6 @@ public Settings( public bool DisableExternalIntegrationsPublishing { get; set; } - public bool SkipQueueCreation { get; set; } - public bool RunCleanupBundle { get; set; } public string RootUrl @@ -131,7 +124,7 @@ public string InstanceId public string StorageUrl => $"{RootUrl}storage"; - public string StagingQueue => $"{ServiceName}.staging"; + public string StagingQueue => $"{InstanceName}.staging"; public int Port { get; private set; } @@ -172,7 +165,8 @@ public TimeSpan HeartbeatGracePeriod public TimeSpan ErrorRetentionPeriod { get; } public TimeSpan EventsRetentionPeriod { get; } - public string ServiceName { get; } + + public string InstanceName { get; init; } = DEFAULT_INSTANCE_NAME; public string TransportConnectionString { get; set; } public TimeSpan ProcessRetryBatchesFrequency { get; set; } @@ -201,7 +195,7 @@ public TransportSettings ToTransportSettings() { var transportSettings = new TransportSettings { - EndpointName = ServiceName, + EndpointName = InstanceName, ConnectionString = TransportConnectionString, MaxConcurrency = MaximumConcurrencyLevel, RunCustomChecks = true, @@ -415,7 +409,7 @@ void LoadErrorIngestionSettings() // logger is intentionally not static to prevent it from being initialized before LoggingConfigurator.ConfigureLogging has been called readonly ILog logger = LogManager.GetLogger(typeof(Settings)); - public const string DEFAULT_SERVICE_NAME = "Particular.ServiceControl"; + public const string DEFAULT_INSTANCE_NAME = "Particular.ServiceControl"; public static readonly SettingsRootNamespace SettingsRootNamespace = new("ServiceControl"); } } \ No newline at end of file diff --git a/src/ServiceControl/Licensing/LicenseController.cs b/src/ServiceControl/Licensing/LicenseController.cs index 6ce8da2f17..c2475f1439 100644 --- a/src/ServiceControl/Licensing/LicenseController.cs +++ b/src/ServiceControl/Licensing/LicenseController.cs @@ -26,7 +26,7 @@ public ActionResult License(bool refresh) ExpirationDate = activeLicense.Details.ExpirationDate?.ToString("O") ?? string.Empty, Status = activeLicense.IsValid ? "valid" : "invalid", LicenseType = activeLicense.Details.LicenseType ?? string.Empty, - InstanceName = settings.ServiceName ?? string.Empty, + InstanceName = settings.InstanceName ?? string.Empty, LicenseStatus = activeLicense.Details.Status }; diff --git a/src/ServiceControl/Licensing/LicensingComponent.cs b/src/ServiceControl/Licensing/LicensingComponent.cs index 243b43d6e3..77f4044da7 100644 --- a/src/ServiceControl/Licensing/LicensingComponent.cs +++ b/src/ServiceControl/Licensing/LicensingComponent.cs @@ -15,7 +15,7 @@ public override void Configure(Settings settings, ITransportCustomization transp hostBuilder.AddLicensingComponent( TransportManifestLibrary.Find(settings.TransportType)?.Name ?? settings.TransportType, settings.ErrorQueue, - settings.ServiceName, + settings.InstanceName, LicenseManager.FindLicense().Details.RegisteredTo, ServiceControlVersion.GetFileVersion()); diff --git a/src/ServiceControl/Notifications/Api/NotificationsController.cs b/src/ServiceControl/Notifications/Api/NotificationsController.cs index 025ccd2d85..f422e27a32 100644 --- a/src/ServiceControl/Notifications/Api/NotificationsController.cs +++ b/src/ServiceControl/Notifications/Api/NotificationsController.cs @@ -71,8 +71,8 @@ public async Task SendTestEmail() { await EmailSender.Send( notificationsSettings.Email, - $"[{settings.ServiceName}] health check notification check successful", - $"[{settings.ServiceName}] health check notification check successful."); + $"[{settings.InstanceName}] health check notification check successful", + $"[{settings.InstanceName}] health check notification check successful."); } catch (Exception e) { diff --git a/src/ServiceControl/Notifications/Email/CustomChecksMailNotification.cs b/src/ServiceControl/Notifications/Email/CustomChecksMailNotification.cs index 2309263276..18a752dbdd 100644 --- a/src/ServiceControl/Notifications/Email/CustomChecksMailNotification.cs +++ b/src/ServiceControl/Notifications/Email/CustomChecksMailNotification.cs @@ -33,7 +33,7 @@ public CustomChecksMailNotification(IMessageSession messageSession, Settings set this.messageSession = messageSession; this.throttlingState = throttlingState; - instanceName = settings.ServiceName; + instanceName = settings.InstanceName; instanceAddress = settings.ApiUrl; if (string.IsNullOrWhiteSpace(settings.NotificationsFilter) == false) diff --git a/src/ServiceControl/Program.cs b/src/ServiceControl/Program.cs index 26b6bb0986..3239e14a08 100644 --- a/src/ServiceControl/Program.cs +++ b/src/ServiceControl/Program.cs @@ -22,6 +22,6 @@ var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace); LoggingConfigurator.ConfigureLogging(loggingSettings); -var settings = new Settings(arguments.ServiceName, loggingSettings: loggingSettings); +var settings = new Settings(loggingSettings: loggingSettings); -await new CommandRunner(arguments.Commands).Execute(arguments, settings); +await new CommandRunner(arguments.Command).Execute(arguments, settings); diff --git a/src/ServiceControlInstaller.Engine.UnitTests/Services/ServiceControllerExTests.cs b/src/ServiceControlInstaller.Engine.UnitTests/Services/ServiceControllerExTests.cs index 65fbcdf0f9..2050488d67 100644 --- a/src/ServiceControlInstaller.Engine.UnitTests/Services/ServiceControllerExTests.cs +++ b/src/ServiceControlInstaller.Engine.UnitTests/Services/ServiceControllerExTests.cs @@ -23,7 +23,7 @@ public void CreateAService() { var s = new WindowsServiceDetails { - ImagePath = @"C:\Program Files (x86)\Particular Software\ServiceControl\ServiceControl.exe --serviceName=Test.SC", + ImagePath = @"C:\Program Files (x86)\Particular Software\ServiceControl\ServiceControl.exe", DisplayName = "Test SC", Name = "Test.SC", ServiceAccount = @"NT Authority\NetworkService", diff --git a/src/ServiceControlInstaller.Engine.UnitTests/Validation/QueueValidationTests.cs b/src/ServiceControlInstaller.Engine.UnitTests/Validation/QueueValidationTests.cs index a06c31bb44..be1ddcbc5b 100644 --- a/src/ServiceControlInstaller.Engine.UnitTests/Validation/QueueValidationTests.cs +++ b/src/ServiceControlInstaller.Engine.UnitTests/Validation/QueueValidationTests.cs @@ -37,6 +37,8 @@ class FakeServiceControlInstance : IServiceControlInstance public string Name { get; set; } + public string InstanceName { get; set; } + public string DisplayName { get; set; } public string ServiceAccount { get; set; } @@ -90,6 +92,8 @@ class FakeServiceControlAuditInstance : IServiceControlAuditInstance public string Name { get; set; } + public string InstanceName { get; set; } + public string DisplayName { get; set; } public string ServiceAccount { get; set; } diff --git a/src/ServiceControlInstaller.Engine/Configuration/Monitoring/AppConfig.cs b/src/ServiceControlInstaller.Engine/Configuration/Monitoring/AppConfig.cs index 7c6d490bce..3a0c42d636 100644 --- a/src/ServiceControlInstaller.Engine/Configuration/Monitoring/AppConfig.cs +++ b/src/ServiceControlInstaller.Engine/Configuration/Monitoring/AppConfig.cs @@ -15,11 +15,16 @@ public void Save() Config.ConnectionStrings.ConnectionStrings.Set("NServiceBus/Transport", details.ConnectionString); var settings = Config.AppSettings.Settings; var version = details.Version; + settings.Set(SettingsList.InstanceName, details.InstanceName, version); settings.Set(SettingsList.Port, details.Port.ToString()); settings.Set(SettingsList.HostName, details.HostName); settings.Set(SettingsList.LogPath, details.LogPath); settings.Set(SettingsList.TransportType, details.TransportPackage.Name, version); settings.Set(SettingsList.ErrorQueue, details.ErrorQueue); + + // Retired settings + settings.RemoveIfRetired(SettingsList.EndpointName, version); + Config.Save(); } diff --git a/src/ServiceControlInstaller.Engine/Configuration/Monitoring/SettingsList.cs b/src/ServiceControlInstaller.Engine/Configuration/Monitoring/SettingsList.cs index e8285944e5..c8aed89e42 100644 --- a/src/ServiceControlInstaller.Engine/Configuration/Monitoring/SettingsList.cs +++ b/src/ServiceControlInstaller.Engine/Configuration/Monitoring/SettingsList.cs @@ -1,11 +1,25 @@ namespace ServiceControlInstaller.Engine.Configuration.Monitoring { + using NuGet.Versioning; + public static class SettingsList { - public static SettingInfo Port = new SettingInfo { Name = "Monitoring/HttpPort" }; - public static SettingInfo HostName = new SettingInfo { Name = "Monitoring/HttpHostName" }; - public static SettingInfo LogPath = new SettingInfo { Name = "Monitoring/LogPath" }; - public static SettingInfo TransportType = new SettingInfo { Name = "Monitoring/TransportType" }; - public static SettingInfo ErrorQueue = new SettingInfo { Name = "Monitoring/ErrorQueue" }; + public static readonly SettingInfo EndpointName = new() + { + Name = "Monitoring/EndpointName", + RemovedFrom = new(5, 5, 0) + }; + + public static SettingInfo InstanceName = new() + { + Name = "Monitoring/InstanceName", + SupportedFrom = new SemanticVersion(5, 5, 0) + }; + + public static SettingInfo Port = new() { Name = "Monitoring/HttpPort" }; + public static SettingInfo HostName = new() { Name = "Monitoring/HttpHostName" }; + public static SettingInfo LogPath = new() { Name = "Monitoring/LogPath" }; + public static SettingInfo TransportType = new() { Name = "Monitoring/TransportType" }; + public static SettingInfo ErrorQueue = new() { Name = "Monitoring/ErrorQueue" }; } } \ No newline at end of file diff --git a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/AuditInstanceSettingsList.cs b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/AuditInstanceSettingsList.cs index 76e2eae4c1..a2b0800cb7 100644 --- a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/AuditInstanceSettingsList.cs +++ b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/AuditInstanceSettingsList.cs @@ -4,19 +4,36 @@ namespace ServiceControlInstaller.Engine.Configuration.ServiceControl public static class AuditInstanceSettingsList { - public static readonly SettingInfo Port = new SettingInfo { Name = "ServiceControl.Audit/Port" }; - public static readonly SettingInfo DatabaseMaintenancePort = new SettingInfo { Name = "ServiceControl.Audit/DatabaseMaintenancePort" }; - public static readonly SettingInfo HostName = new SettingInfo { Name = "ServiceControl.Audit/HostName" }; - public static readonly SettingInfo LogPath = new SettingInfo { Name = "ServiceControl.Audit/LogPath" }; - public static readonly SettingInfo DBPath = new SettingInfo { Name = "ServiceControl.Audit/DBPath" }; - public static readonly SettingInfo ForwardAuditMessages = new SettingInfo { Name = "ServiceControl.Audit/ForwardAuditMessages" }; - public static readonly SettingInfo TransportType = new SettingInfo { Name = "ServiceControl.Audit/TransportType" }; - public static readonly SettingInfo PersistenceType = new SettingInfo { Name = "ServiceControl.Audit/PersistenceType" }; - public static readonly SettingInfo AuditQueue = new SettingInfo { Name = "ServiceBus/AuditQueue" }; - public static readonly SettingInfo AuditLogQueue = new SettingInfo { Name = "ServiceBus/AuditLogQueue" }; - public static readonly SettingInfo AuditRetentionPeriod = new SettingInfo { Name = "ServiceControl.Audit/AuditRetentionPeriod" }; - public static readonly SettingInfo MaintenanceMode = new SettingInfo { Name = "ServiceControl.Audit/MaintenanceMode" }; - public static readonly SettingInfo ServiceControlQueueAddress = new SettingInfo { Name = "ServiceControl.Audit/ServiceControlQueueAddress" }; - public static readonly SettingInfo EnableFullTextSearchOnBodies = new SettingInfo { Name = "ServiceControl.Audit/EnableFullTextSearchOnBodies", SupportedFrom = new SemanticVersion(4, 17, 0) }; + public static readonly SettingInfo InternalQueueName = new() + { + Name = "ServiceControl.Audit/InternalQueueName", + RemovedFrom = new(5, 5, 0) + }; + + public static readonly SettingInfo InstanceName = new() + { + Name = "ServiceControl.Audit/InstanceName", + SupportedFrom = new SemanticVersion(5, 5, 0) + }; + + public static readonly SettingInfo Port = new() { Name = "ServiceControl.Audit/Port" }; + public static readonly SettingInfo DatabaseMaintenancePort = new() { Name = "ServiceControl.Audit/DatabaseMaintenancePort" }; + public static readonly SettingInfo HostName = new() { Name = "ServiceControl.Audit/HostName" }; + public static readonly SettingInfo LogPath = new() { Name = "ServiceControl.Audit/LogPath" }; + public static readonly SettingInfo DBPath = new() { Name = "ServiceControl.Audit/DBPath" }; + public static readonly SettingInfo ForwardAuditMessages = new() { Name = "ServiceControl.Audit/ForwardAuditMessages" }; + public static readonly SettingInfo TransportType = new() { Name = "ServiceControl.Audit/TransportType" }; + public static readonly SettingInfo PersistenceType = new() { Name = "ServiceControl.Audit/PersistenceType" }; + public static readonly SettingInfo AuditQueue = new() { Name = "ServiceBus/AuditQueue" }; + public static readonly SettingInfo AuditLogQueue = new() { Name = "ServiceBus/AuditLogQueue" }; + public static readonly SettingInfo AuditRetentionPeriod = new() { Name = "ServiceControl.Audit/AuditRetentionPeriod" }; + public static readonly SettingInfo MaintenanceMode = new() { Name = "ServiceControl.Audit/MaintenanceMode" }; + public static readonly SettingInfo ServiceControlQueueAddress = new() { Name = "ServiceControl.Audit/ServiceControlQueueAddress" }; + + public static readonly SettingInfo EnableFullTextSearchOnBodies = new() + { + Name = "ServiceControl.Audit/EnableFullTextSearchOnBodies", + SupportedFrom = new SemanticVersion(4, 17, 0) + }; } } \ No newline at end of file diff --git a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAppConfig.cs b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAppConfig.cs index b5d5da3d50..950058cfa7 100644 --- a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAppConfig.cs +++ b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAppConfig.cs @@ -15,6 +15,7 @@ protected override void UpdateSettings() Config.ConnectionStrings.ConnectionStrings.Set("NServiceBus/Transport", details.ConnectionString); var settings = Config.AppSettings.Settings; var version = details.Version; + settings.Set(ServiceControlSettings.InstanceName, details.InstanceName, version); settings.Set(ServiceControlSettings.VirtualDirectory, details.VirtualDirectory); settings.Set(ServiceControlSettings.Port, details.Port.ToString()); settings.Set(ServiceControlSettings.DatabaseMaintenancePort, details.DatabaseMaintenancePort.ToString(), version); @@ -35,6 +36,7 @@ protected override void UpdateSettings() settings.RemoveIfRetired(ServiceControlSettings.AuditQueue, version); settings.RemoveIfRetired(ServiceControlSettings.AuditLogQueue, version); settings.RemoveIfRetired(ServiceControlSettings.ForwardAuditMessages, version); + settings.RemoveIfRetired(ServiceControlSettings.InternalQueueName, version); RemoveRavenDB35Settings(settings, version); } diff --git a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAuditAppConfig.cs b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAuditAppConfig.cs index 666ca0137e..bcbae4a3e1 100644 --- a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAuditAppConfig.cs +++ b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAuditAppConfig.cs @@ -17,6 +17,7 @@ protected override void UpdateSettings() Config.ConnectionStrings.ConnectionStrings.Set("NServiceBus/Transport", instance.ConnectionString); var settings = Config.AppSettings.Settings; var version = instance.Version; + settings.Set(AuditInstanceSettingsList.InstanceName, instance.InstanceName, version); settings.Set(AuditInstanceSettingsList.Port, instance.Port.ToString()); settings.Set(AuditInstanceSettingsList.HostName, instance.HostName); settings.Set(AuditInstanceSettingsList.LogPath, instance.LogPath); @@ -65,6 +66,9 @@ protected override void UpdateSettings() } } + // Retired setting + settings.RemoveIfRetired(AuditInstanceSettingsList.InternalQueueName, version); + RemoveRavenDB35Settings(settings, version); } diff --git a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/SettingsList.cs b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/SettingsList.cs index bf907971a3..bd0b5e4c87 100644 --- a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/SettingsList.cs +++ b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/SettingsList.cs @@ -5,6 +5,18 @@ namespace ServiceControlInstaller.Engine.Configuration.ServiceControl // See Compatibility.cs for version switching that isn't related to Settings public static class ServiceControlSettings { + public static readonly SettingInfo InternalQueueName = new() + { + Name = "ServiceControl/InternalQueueName", + RemovedFrom = new(5, 5, 0) + }; + + public static readonly SettingInfo InstanceName = new() + { + Name = "ServiceControl/InstanceName", + SupportedFrom = new SemanticVersion(5, 5, 0) + }; + public static readonly SettingInfo VirtualDirectory = new() { Name = "ServiceControl/VirtualDirectory" }; public static readonly SettingInfo Port = new() { Name = "ServiceControl/Port" }; public static readonly SettingInfo DatabaseMaintenancePort = new SettingInfo diff --git a/src/ServiceControlInstaller.Engine/Instances/BaseService.cs b/src/ServiceControlInstaller.Engine/Instances/BaseService.cs index 0b17675cfa..493b413469 100644 --- a/src/ServiceControlInstaller.Engine/Instances/BaseService.cs +++ b/src/ServiceControlInstaller.Engine/Instances/BaseService.cs @@ -4,7 +4,6 @@ using System.Diagnostics; using System.IO; using System.Linq; - using System.Runtime; using System.ServiceProcess; using System.Threading; using Engine; @@ -16,11 +15,19 @@ public abstract class BaseService : IServiceInstance { public string Description { get; set; } + public IWindowsServiceController Service { get; set; } + public string InstallPath => Path.GetDirectoryName(Service.ExePath); + public string DisplayName { get; set; } + public string Name => Service.ServiceName; + + public string InstanceName { get; set; } + public string ServiceAccount { get; set; } + public string ServiceAccountPwd { get; set; } public TransportInfo TransportPackage { get; set; } @@ -232,7 +239,6 @@ void MoveNewToCurrent(string newPath, string oldPath) } } - static void PurgeOld(string oldPath) { try diff --git a/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs b/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs index a5b2b5bb88..aaef5a93af 100644 --- a/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs @@ -27,12 +27,19 @@ public MonitoringInstance(WindowsServiceController service) } public AppConfig AppConfig { get; set; } + public ReportCard ReportCard { get; set; } + public int Port { get; set; } + public string HostName { get; set; } + public string ErrorQueue { get; set; } + public string ConnectionString { get; set; } + public string LogPath { get; set; } + public bool SkipQueueCreation { get; set; } public string Url => $"http://{HostName}:{Port}/"; @@ -56,6 +63,8 @@ public override void Reload() Service.Refresh(); AppConfig = new AppConfig(this); + + InstanceName = AppConfig.Read(SettingsList.InstanceName, Name); HostName = AppConfig.Read(SettingsList.HostName, "localhost"); Port = AppConfig.Read(SettingsList.Port, 1234); LogPath = AppConfig.Read(SettingsList.LogPath, DefaultLogPath()); @@ -66,7 +75,6 @@ public override void Reload() ServiceAccount = Service.Account; } - string DefaultLogPath() { var userAccountName = UserAccount.ParseAccountName(Service.Account); diff --git a/src/ServiceControlInstaller.Engine/Instances/MonitoringNewInstance.cs b/src/ServiceControlInstaller.Engine/Instances/MonitoringNewInstance.cs index 6857518e35..0459a5a66d 100644 --- a/src/ServiceControlInstaller.Engine/Instances/MonitoringNewInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/MonitoringNewInstance.cs @@ -41,23 +41,30 @@ string[] FlagFiles } public string HostName { get; set; } + public int Port { get; set; } public string ErrorQueue { get; set; } - public string InstallPath { get; set; } + public string LogPath { get; set; } public TransportInfo TransportPackage { get; set; } + public string ConnectionString { get; set; } public string Name { get; set; } + + public string InstanceName { get; set; } + public string DisplayName { get; set; } + public string ServiceAccount { get; set; } + public string ServiceAccountPwd { get; set; } - public bool SkipQueueCreation { get; set; } + public bool SkipQueueCreation { get; set; } public SemanticVersion Version { get; } @@ -106,7 +113,7 @@ public void RegisterService() ServiceAccountPwd = ServiceAccountPwd, DisplayName = DisplayName, Name = Name, - ImagePath = $"\"{Path.Combine(InstallPath, Constants.MonitoringExe)}\" --serviceName={Name}", + ImagePath = $"\"{Path.Combine(InstallPath, Constants.MonitoringExe)}\"", ServiceDescription = ServiceDescription }; var dependencies = new List diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs index 425d9981fb..30a0bc6654 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs @@ -70,6 +70,10 @@ public override void Reload() Service.Refresh(); AppConfig = CreateAppConfig(); + + InstanceName = AppConfig.Read(AuditInstanceSettingsList.InternalQueueName, Name); + InstanceName = AppConfig.Read(AuditInstanceSettingsList.InstanceName, InstanceName); + HostName = AppConfig.Read(AuditInstanceSettingsList.HostName, "localhost"); Port = AppConfig.Read(AuditInstanceSettingsList.Port, 33333); DatabaseMaintenancePort = AppConfig.Read(AuditInstanceSettingsList.DatabaseMaintenancePort, null); diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditNewInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditNewInstance.cs index fc4f27ace3..46c9150364 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditNewInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditNewInstance.cs @@ -53,7 +53,7 @@ internal override WindowsServiceDetails GetWindowsServiceDetails() ServiceAccountPwd = ServiceAccountPwd, DisplayName = DisplayName, Name = Name, - ImagePath = $"\"{Path.Combine(InstallPath, Constants.ServiceControlAuditExe)}\" --serviceName={Name}", + ImagePath = $"\"{Path.Combine(InstallPath, Constants.ServiceControlAuditExe)}\"", ServiceDescription = ServiceDescription }; } diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstallableBase.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstallableBase.cs index e5c4f93665..ddcdc85eed 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstallableBase.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstallableBase.cs @@ -69,23 +69,43 @@ string[] FlagFiles } public string LogPath { get; set; } + public string DBPath { get; set; } + public string HostName { get; set; } + public string InstallPath { get; set; } + public int Port { get; set; } + public int? DatabaseMaintenancePort { get; set; } + public string VirtualDirectory { get; set; } + public string ErrorQueue { get; set; } + public string ErrorLogQueue { get; set; } + public string AuditQueue { get; set; } + public string AuditLogQueue { get; set; } + public bool ForwardAuditMessages { get; set; } + public bool ForwardErrorMessages { get; set; } + public TransportInfo TransportPackage { get; set; } + public string ConnectionString { get; set; } + public string Name { get; set; } + + public string InstanceName { get; set; } + public string DisplayName { get; set; } + public bool SkipQueueCreation { get; set; } + public bool EnableFullTextSearchOnBodies { get; set; } [XmlIgnore] diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs index 76358ba9fb..a444dc1063 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs @@ -102,6 +102,10 @@ public override void Reload() Service.Refresh(); AppConfig = CreateAppConfig(); + + InstanceName = AppConfig.Read(ServiceControlSettings.InternalQueueName, Name); + InstanceName = AppConfig.Read(ServiceControlSettings.InstanceName, InstanceName); + HostName = AppConfig.Read(ServiceControlSettings.HostName, "localhost"); Port = AppConfig.Read(ServiceControlSettings.Port, 33333); DatabaseMaintenancePort = AppConfig.Read(ServiceControlSettings.DatabaseMaintenancePort, null); diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlNewInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlNewInstance.cs index 38c386a09d..b234b6211c 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlNewInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlNewInstance.cs @@ -80,7 +80,7 @@ internal override WindowsServiceDetails GetWindowsServiceDetails() ServiceAccountPwd = ServiceAccountPwd, DisplayName = DisplayName, Name = Name, - ImagePath = $"\"{Path.Combine(InstallPath, Constants.ServiceControlExe)}\" --serviceName={Name}", + ImagePath = $"\"{Path.Combine(InstallPath, Constants.ServiceControlExe)}\"", ServiceDescription = ServiceDescription }; } diff --git a/src/ServiceControlInstaller.Engine/Interfaces.cs b/src/ServiceControlInstaller.Engine/Interfaces.cs index 6f45367523..54a1c8728f 100644 --- a/src/ServiceControlInstaller.Engine/Interfaces.cs +++ b/src/ServiceControlInstaller.Engine/Interfaces.cs @@ -61,6 +61,9 @@ public interface IURLInfo public interface IServiceInstance : IServiceAccount, IVersionInfo { string Name { get; } + + string InstanceName { get; } + string DisplayName { get; } } diff --git a/src/ServiceControlInstaller.Engine/Queues/QueueCreation.cs b/src/ServiceControlInstaller.Engine/Queues/QueueCreation.cs index 8948608917..7ed3f6425a 100644 --- a/src/ServiceControlInstaller.Engine/Queues/QueueCreation.cs +++ b/src/ServiceControlInstaller.Engine/Queues/QueueCreation.cs @@ -3,51 +3,37 @@ using System; using System.Diagnostics; using System.IO; - using Accounts; using Instances; static class QueueCreation { public static void RunQueueCreation(IServiceControlInstance instance) { - var accountName = instance.ServiceAccount; RunQueueCreation(instance.InstallPath, Constants.ServiceControlExe, instance.Name, - accountName, instance.SkipQueueCreation); } public static void RunQueueCreation(IServiceControlAuditInstance instance) { - var accountName = instance.ServiceAccount; RunQueueCreation(instance.InstallPath, Constants.ServiceControlAuditExe, instance.Name, - accountName, instance.SkipQueueCreation); } public static void RunQueueCreation(IMonitoringInstance instance) { - var accountName = instance.ServiceAccount; RunQueueCreation(instance.InstallPath, Constants.MonitoringExe, instance.Name, - accountName, instance.SkipQueueCreation); } - static void RunQueueCreation(string installPath, string exeName, string serviceName, string serviceAccount, bool skipQueueCreation = false) + static void RunQueueCreation(string installPath, string exeName, string instanceName, bool skipQueueCreation = false) { - var userAccount = UserAccount.ParseAccountName(serviceAccount); - - var args = $"--setup --serviceName={serviceName}"; - - if (!userAccount.IsLocalSystem()) - { - args += $" --userName=\"{userAccount.QualifiedName}\""; - } + var args = $"--setup"; if (skipQueueCreation) { @@ -64,6 +50,8 @@ static void RunQueueCreation(string installPath, string exeName, string serviceN RedirectStandardError = true }; + processStartupInfo.EnvironmentVariables.Add("INSTANCE_NAME", instanceName); + var p = Process.Start(processStartupInfo); if (p != null) {