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 :(
                BusPerformanceCounters.Install();
            });

            configurator.Service(settings =>
            {
                _bootstrapper = BootstrapperFactory(settings);

                return(_bootstrapper.GetService());
            },
                                 s => s.AfterStoppingService(() =>
            {
                if (_bootstrapper != default(T))
                {
                    _bootstrapper.Dispose();
                }
            }));
        }
示例#2
0
        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 :(
                    BusPerformanceCounters.Install();
                });

                x.Service(CreateService);
            }));
        }