public void Configure(HostConfigurator configurator) { configurator.SetServiceName(ServiceName); configurator.SetDisplayName(DisplayName); configurator.SetDescription(Description); configurator.AfterInstall(() => { VerifyEventLogSourceExists(ServiceName); // this will force the performance counters to register during service installation // making them created - of course using the InstallUtil stuff completely skips // this part of the install :( ServiceBusPerformanceCounters counters = ServiceBusPerformanceCounters.Instance; }); configurator.Service(settings => { OnStarting(settings); _bootstrapper = BootstrapperFactory(settings); return(_bootstrapper.GetService()); }, s => s.AfterStoppingService(() => { if (_bootstrapper != default(T)) { _bootstrapper.Dispose(); } })); }
static int Main() { Log4NetLogWriterFactory.Use("log4net.config"); Log4NetLogger.Use(); return((int)HostFactory.Run(x => { x.AfterInstall(() => { VerifyEventLogSourceExists(); // this will force the performance counters to register during service installation // making them created - of course using the InstallUtil stuff completely skips // this part of the install :( ServiceBusPerformanceCounters counters = ServiceBusPerformanceCounters.Instance; string name = counters.ConsumerThreadCount.Name; Console.WriteLine("Consumer Thread Count Counter Installed: {0}", name); }); x.Service(CreateService); })); }