Exemple #1
0
        private static void SetServiceConfigurations(HostConfigurator <Service> config, IPowerShellWorker powerShellWorker)
        {
            const string name        = "RemoteControllerClient";
            const string displayName = "Remote Controller Client";
            const string description = "Servico para permitir o controle do computador remotamente atraves de CLI";

            config.SetName(name);

            config.SetDisplayName(displayName);

            config.SetDescription(description);

            config.Service(serviceConfig =>
            {
                serviceConfig.ServiceFactory((extraArguments, microServiceController) => new Service(microServiceController, powerShellWorker));

                serviceConfig.OnStart((service, extraArguments) => { service.Start(); });

                serviceConfig.OnStop(service => { service.Stop(); });

                serviceConfig.OnInstall(service => { Console.WriteLine($"Instalando servico {name}"); });

                serviceConfig.OnUnInstall(service => { Console.WriteLine($"Desinstalando servico {name}"); });

                serviceConfig.OnPause(service => { Console.WriteLine($"Servico {name} pausado"); });

                serviceConfig.OnError(e => { Console.WriteLine($"Ocorreu um erro no servico, excessao: {e.Message}"); });
            });
        }
        public static HostConfigurator UsingQuartzJobFactory <TJobFactory>(this HostConfigurator configurator)
            where TJobFactory : IJobFactory, new()
        {
            _ = configurator ?? throw new ArgumentNullException(nameof(configurator));

            return(UsingQuartzJobFactory(configurator, () => new TJobFactory()));
        }
Exemple #3
0
        public void ApplyTo(HostConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException("configurator");

            configurator.UseHostBuilder((environment, settings) => new StopBuilder(environment, settings));
        }
Exemple #4
0
 /// <summary>
 /// Applies the configuration options.
 /// </summary>
 /// <param name="configurator">The host configurator.</param>
 /// <param name="options">The configuration options.</param>
 public static void ApplyOptions(this HostConfigurator configurator, IEnumerable <Option> options)
 {
     foreach (var option in options)
     {
         option.ApplyTo(configurator);
     }
 }
Exemple #5
0
        private static void InitService(HostConfigurator config, ILifetimeScope container)
        {
            config.UseAutofacContainer(container);

            config.Service <MediaIndexingService>(sc =>
            {
                sc.ConstructUsingAutofacContainer();
                sc.WhenStarted(s => s.Start());
                sc.WhenStopped(s => s.Stop());

                sc.WebApiEndpoint(api => api
                                  .OnLocalhost() // defaults to port 8080
                                  .ConfigureServer(c => c.MapHttpAttributeRoutes())
                                  .UseDependencyResolver(new AutofacWebApiDependencyResolver(container)));
            });

            config.RunAsLocalSystem();
            config.StartAutomatically();

            config.SetDescription("Media indexing service for indexing images and videos");
            config.SetDisplayName("Media Indexing Service");
            config.SetServiceName("MediaIndexingService");

            config.UseLog4Net();
        }
Exemple #6
0
        public void ApplyTo(HostConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException("configurator");

            configurator.SetInstanceName(_instanceName);
        }
Exemple #7
0
 public static HostConfigurator UseUnityContainer(
     this HostConfigurator configurator,
     IUnityContainer unityContainer)
 {
     configurator.AddConfigurator(new UnityHostBuilderConfigurator(unityContainer));
     return(configurator);
 }
Exemple #8
0
        public static (SourceSettings, AwsDestinationSettings) Parse(HostConfigurator x)
        {
            string sourceDirectoryPath = string.Empty;
            int    sourceBufferSecs    = 2;
            string awsBucketName       = string.Empty;
            string awsBucketRegion     = string.Empty;
            string awsAccessKeyId      = string.Empty;
            string awsSecretkey        = string.Empty;

            x.AddCommandLineDefinition(nameof(sourceDirectoryPath), v => sourceDirectoryPath = v);
            x.AddCommandLineDefinition(nameof(sourceBufferSecs), v => sourceBufferSecs       = int.Parse(v));
            x.AddCommandLineDefinition(nameof(awsBucketName), v => awsBucketName             = v);
            x.AddCommandLineDefinition(nameof(awsBucketRegion), v => awsBucketRegion         = v);
            x.AddCommandLineDefinition(nameof(awsAccessKeyId), v => awsAccessKeyId           = v);
            x.AddCommandLineDefinition(nameof(awsSecretkey), v => awsSecretkey = v);
            x.ApplyCommandLine();

            var sourceSettings = new SourceSettings(sourceDirectoryPath, sourceBufferSecs);

            var destinationSettings = new AwsDestinationSettings(
                awsBucketName,
                awsBucketRegion,
                awsAccessKeyId,
                awsSecretkey);

            return(sourceSettings, destinationSettings);
        }
        static void ConfigureHost(HostConfigurator x)
        {
            x.UseSerilog();
            x.Service <ILifetimeScope>(
                s =>
            {
                s.ConstructUsing(serviceFactory => _container.BeginLifetimeScope());
                s.WhenStarted(scope => Task.Run(async() =>
                {
                    try
                    {
                        await scope.Resolve <PapercutServerService>().Start();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Exception Caught Running Service");
                    }
                }));
                s.WhenStopped(scope => scope.Resolve <PapercutServerService>().Stop().Wait());
                s.WhenShutdown(scope => scope.Dispose());
            });

            x.RunAsLocalSystem();

            x.SetDescription("Papercut SMTP Backend Service");
            x.SetDisplayName("Papercut SMTP Service");
            x.SetServiceName("PapercutServerService");
        }
Exemple #10
0
        private static void ConfigureNlog(HostConfigurator configurator, Service service)
        {
            var path = Path.Combine(service.HostConfig.Configs.FullName, "nlog.config");

            LogManager.Configuration = new XmlLoggingConfiguration(path);
            configurator.UseNLog(LogManager.GetLogger(typeof(Run).FullName).Factory);
        }
Exemple #11
0
        public static void ConfigureService <TService, TRegistry>(this HostConfigurator configurator,
                                                                  Func <IContainer, TRegistry> registry,
                                                                  Action <TService> start, Action <TService> stop)
            where TRegistry : Registry
            where TService : class
        {
            var container = new Container(x =>
            {
                x.For <IConfiguration>()
                .Singleton()
                .Add <Configuration>();

                x.For <TService>()
                .Singleton()
                .Use <TService>();
            });

            container.Configure(x => x.AddRegistry(registry(container)));

            configurator.Service <TService>(service =>
            {
                service.ConstructUsing(builder => container.GetInstance <TService>());
                service.WhenStarted(start);
                service.WhenStopped(stop);
            });
        }
Exemple #12
0
 public static void InitializeLoggers(this HostConfigurator hostConfigurator, Assembly assembly, DirectoryInfo logs)
 {
     if (NlogDetectedIn(assembly))
     {
         ConfigureNLog(hostConfigurator, logs);
     }
 }
Exemple #13
0
        private void SetServiceConfigurationInfo(HostConfigurator hostConfig)
        {
            var serviceName = "Order Microservice";
            var displayName = "Order MS";

            hostConfig.SetServiceName(serviceName);
        }
Exemple #14
0
        /// <summary>
        /// Конфигурация сервиса средствами Topshelf.
        /// </summary>
        private static void ConfigureService
        (
            HostConfigurator configurator
        )
        {
            configurator.ApplyCommandLine();

            var service = configurator.Service <DummyService>();

            service.SetDescription("My Dummy service for learning");
            service.SetDisplayName("Dummy Service");
            service.SetServiceName("DummyService");

            service.StartAutomaticallyDelayed();
            service.RunAsLocalSystem();
            service.EnableShutdown();

            service.UseNLog();

            // Необязательная настройка восстановления после сбоев
            service.EnableServiceRecovery(recovery =>
            {
                recovery.RestartService(1);
            });

            // Реакция на исключение
            service.OnException(exception =>
            {
                var log = HostLogger.Get <DummyService>();
                log.ErrorFormat($"Exception {exception}");
            });
        }
Exemple #15
0
        /// <summary>
        /// Applies the option to the specified host configurator.
        /// </summary>
        /// <param name="configurator">The host configurator.</param>
        public void ApplyTo(HostConfigurator configurator)
        {
            var recoveryHostConfigurator = new ServiceRecoveryHostConfigurator();

            foreach (var option in serviceRecoveryOptions.Actions)
            {
                switch (option)
                {
                case RestartServiceRecoveryAction restartServiceRecoveryAction:
                    recoveryHostConfigurator.RestartService(restartServiceRecoveryAction.Delay / 60000);
                    break;

                case RestartSystemRecoveryAction restartSystemRecoveryAction:
                    recoveryHostConfigurator.RestartComputer(restartSystemRecoveryAction.Delay / 60000, restartSystemRecoveryAction.RestartMessage);
                    break;

                case RunProgramRecoveryAction runProgramRecoveryAction:
                    recoveryHostConfigurator.RunProgram(runProgramRecoveryAction.Delay / 60000, runProgramRecoveryAction.Command);
                    break;
                }
            }

            if (this.serviceRecoveryOptions.RecoverOnCrashOnly)
            {
                recoveryHostConfigurator.OnCrashOnly();
            }

            recoveryHostConfigurator.SetResetPeriod(this.serviceRecoveryOptions.ResetPeriod);

            configurator.AddConfigurator(recoveryHostConfigurator);
        }
Exemple #16
0
        public void ApplyTo(HostConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException("configurator");

            configurator.AddConfigurator(new SudoConfigurator());
        }
Exemple #17
0
        public static void Configure(HostConfigurator config)
        {
            // http://docs.topshelf-project.com/en/latest/
            Logger.Debug("Configuring windows service");
            config.Service <WindowsService>(ConfigureServiceClass);

            // prompt for credentials - Sys Admins will need to type password for SchTasks.Admin user
            config.RunAsPrompt();

            config.SetDescription("Cyrus MicroServices Background Processing (Multiple Mini-Apps)");
            config.SetDisplayName("Cyrus MicroServices");
            config.SetServiceName("Cyrus.MicroServices");

            //TODO: windows service settings
            //config.SetDescription(AppSettings.Default.WindowsService.Description);
            //config.SetDisplayName(AppSettings.Default.WindowsService.DisplayName);
            //config.SetServiceName(AppSettings.Default.WindowsService.Name);

            config.StartAutomatically();
            config.UseNLog();

            config.EnableServiceRecovery(rc =>
            {
                rc.RestartService(delayInMinutes: 2);
                //rc.RestartService(AppSettings.Default.WindowsService.RecoverRestartAfterMins);
            });

            Logger.Debug("Windows service configured");
        }
        private void SetServiceRunAs(HostConfigurator x)
        {
            switch (ServiceRunAs)
            {
            case ServiceRunAs.LocalService:
                x.RunAsLocalService();
                break;

            case ServiceRunAs.LocalSystem:
                x.RunAsLocalSystem();
                break;

            case ServiceRunAs.NetworkService:
                x.RunAsNetworkService();
                break;

            case ServiceRunAs.Prompt:
                x.RunAsPrompt();
                break;

            case ServiceRunAs.UserLogin:
                x.RunAs(UserName, UserPassword);
                break;
            }
        }
        public static void Configure(HostConfigurator config)
        {
            // http://docs.topshelf-project.com/en/latest/
            Logger.Debug("Configuring windows service");
            config.Service<WindowsService>(ConfigureServiceClass);

            // prompt for credentials - Sys Admins will need to type password for SchTasks.Admin user
            config.RunAsPrompt();

            config.SetDescription("Cyrus MicroServices Background Processing (Multiple Mini-Apps)");
            config.SetDisplayName("Cyrus MicroServices");
            config.SetServiceName("Cyrus.MicroServices");

            //TODO: windows service settings
            //config.SetDescription(AppSettings.Default.WindowsService.Description);
            //config.SetDisplayName(AppSettings.Default.WindowsService.DisplayName);
            //config.SetServiceName(AppSettings.Default.WindowsService.Name);

            config.StartAutomatically();
            config.UseNLog();

            config.EnableServiceRecovery(rc =>
            {
                rc.RestartService(delayInMinutes: 2);
                //rc.RestartService(AppSettings.Default.WindowsService.RecoverRestartAfterMins);
            });

            Logger.Debug("Windows service configured");
        }
Exemple #20
0
        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();
                }
            }));
        }
Exemple #21
0
        static void Configure(HostConfigurator hostConfigurator)
        {
            hostConfigurator.Service <SchedulerService>(s =>
            {
                // TopShelf will create a new Service every time you Stop/Start within Windows Services.
                s.ConstructUsing(() =>
                {
                    var builder = new ContainerBuilder();

                    // Service Bus
                    builder.AddMassTransit(cfg =>
                    {
                        cfg.AddBus(ConfigureBus);
                    });

                    // Should Only ever register one Service
                    builder.RegisterType <SchedulerService>()
                    .SingleInstance();

                    builder.Register(x => new StdSchedulerFactory().GetScheduler().ConfigureAwait(false).GetAwaiter().GetResult())
                    .SingleInstance();

                    var container = builder.Build();

                    return(container.Resolve <SchedulerService>());
                });

                s.WhenStarted((service, control) => service.Start());
                s.WhenStopped((service, control) => service.Stop());
            });

            hostConfigurator.SetDisplayName("MT.Net461.Scheduler");
            hostConfigurator.SetServiceName("MT.Net461.Scheduler");
            hostConfigurator.SetDescription("MT.Net461.Scheduler");
        }
        public static IDisposable UseApplicationHostBuilder(this HostConfigurator hostConfigurator, string[] commandLineArguments)
        {
            hostConfigurator.UseHostBuilder((environment, settings) => new ApplicationHostBuilder(environment, settings));
            var commandLine = string.Join(" ", commandLineArguments);

            return(new DisposableAction(() => hostConfigurator.ApplyCommandLine(commandLine)));
        }
Exemple #23
0
 public static HostConfigurator UseWindsor(
     this HostConfigurator configurator,
     Action <IWindsorContainer> action)
 {
     configurator.AddConfigurator(new WindsorHostBuilderConfigurator(action));
     return(configurator);
 }
        public static HostConfigurator WithStartParameter(this HostConfigurator configurator, string name, string value,
                                                          Action <string> action)
        {
            Add(configurator, name, value);
            configurator.AddCommandLineDefinition(name, action);

            return(configurator);
        }
        public static HostConfigurator WithStartParameter(this HostConfigurator configurator, string installName, string runtimeName,
                                                          Func <string, string> installAction, Action <string> runtimeAction)
        {
            configurator.AddCommandLineDefinition(runtimeName, runtimeAction);
            configurator.AddCommandLineDefinition(installName, s => Add(configurator, runtimeName, installAction(s)));

            return(configurator);
        }
        /// <summary>
        /// Bind Quartz to Topshelf host configurator and Autofac.
        /// </summary>
        /// <param name="configurator">Topshelf host configurator.</param>
        /// <param name="lifetimeScope">Autofac lifetime scope.</param>
        /// <returns>Host configurator for Topshelf.</returns>
        public static HostConfigurator UseQuartzAutofac(this HostConfigurator configurator, ILifetimeScope lifetimeScope)
        {
            _ = lifetimeScope ?? throw new ArgumentNullException(nameof(lifetimeScope));
            _ = configurator ?? throw new ArgumentNullException(nameof(configurator));

            AutofacScheduleJobServiceConfiguratorExtensions.SetupAutofac(lifetimeScope);
            return(configurator);
        }
Exemple #27
0
 /// <summary>
 ///     Specify that you want to use the Serilog logging engine.
 /// </summary>
 /// <param name="configurator"></param>
 /// <param name="logger">Serilog logger to use.</param>
 public static void UseSerilog(this HostConfigurator configurator, ILogger logger)
 {
     if (logger == null)
     {
         throw new ArgumentNullException("logger");
     }
     HostLogger.UseLogger(new SerilogHostLoggerConfigurator(logger));
 }
        internal static List <Tuple <string, string> > Commands(HostConfigurator configurator)
        {
            List <Tuple <string, string> > pairs;

            ActionTable.TryGetValue(configurator, out pairs);

            return(pairs);
        }
        public static HostConfigurator WithConstantStartParameter(this HostConfigurator configurator, string name, string constantValue,
                                                                  Action <string> runtimeAction)
        {
            Add(configurator, name, constantValue);
            configurator.AddCommandLineDefinition(name, runtimeAction);

            return(configurator);
        }
Exemple #30
0
        public static HostConfigurator UseQuartzLamar(this HostConfigurator configurator, Container container)
        {
            configurator.UseLamar(container);

            LamarScheduleJobServiceConfiguratorExtensions.SetupLamar();

            return(configurator);
        }
        public static HostConfigurator WithStartParameter(this HostConfigurator configurator, string name,
                                                          Action <string> action)
        {
            configurator.AddCommandLineDefinition(Prefix + name, action);
            configurator.AddCommandLineDefinition(name, s => Add(configurator, Prefix + name, s));

            return(configurator);
        }
Exemple #32
0
        public static HostConfigurator AddDependency(this HostConfigurator configurator, string name)
        {
            var dependencyConfigurator = new DependencyHostConfigurator(name);

            configurator.AddConfigurator(dependencyConfigurator);

            return(configurator);
        }
        public SpHostServiceInstaller(HostSettings settings, HostConfigurator configurator)
        {
            _hostConfigurator = configurator;

            _installer = CreateInstaller(settings);

            _transactedInstaller = CreateTransactedInstaller(_installer);
        }
Exemple #34
0
        public SpHostServiceInstaller(HostSettings settings, HostConfigurator configurator)
        {
            _hostConfigurator = configurator;

            _installer = CreateInstaller(settings);

            _transactedInstaller = CreateTransactedInstaller(_installer);
        }
Exemple #35
0
 public static HostConfigurator ConfigureLogging(this HostConfigurator config, string serviceName, string machineName, string logName)
 {
     config.DependsOnEventLog();
     config.BeforeInstall(settings => CreateEventLogSource(serviceName, machineName, logName));
     config.BeforeUninstall(() => DeleteEventLogSource(serviceName, machineName));
     config.UseSerilog();
     return(config);
 }
Exemple #36
0
        public void ApplyTo(HostConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException("configurator");

            var startConfigurator = new StartConfigurator();

            configurator.AddConfigurator(startConfigurator);
        }
Exemple #37
0
        public void ApplyTo(HostConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException("configurator");

            var commandConfigurator = new CommandConfigurator(_command);

            configurator.AddConfigurator(commandConfigurator);
        }
 protected override void Configure(HostConfigurator hostConfigurator)
 {
     string svcBusConnection = CloudConfigurationManager.GetSetting("ServiceBusConnectionString_Producer");
     var queueName = CloudConfigurationManager.GetSetting("PublishingQueueName");
     hostConfigurator.Service(s => new Producer(svcBusConnection,queueName), x =>
     {
         x.BeforeStartingService(ctxt => _log.Info("Starting Producer service"));
         x.AfterStoppingService(ctxt => _log.Info("Producer service stopped"));
     });
 }
Exemple #39
0
        protected override void Configure(HostConfigurator hostConfigurator)
        {
            // load azure settings here
            string testPhrase = CloudConfigurationManager.GetSetting("TestPhrase");

            hostConfigurator.Service(settings => new SampleService(testPhrase), x =>
            {
                x.BeforeStartingService(context => _log.Info("Before starting service!!"));
                x.AfterStoppingService(context => _log.Info("After stopping service!!"));
            });
        }
Exemple #40
0
 private void SetupService(HostConfigurator configurator, ILifetimeScope container)
 {
     configurator.AutofacService<IAgarIoService>(container, serviceConfigurator =>
     {
         serviceConfigurator.WhenStarted(s => s.Start());
         serviceConfigurator.WhenStopped(s => s.Stop());
     });
     configurator.SetServiceName("AgarIo.Service");
     configurator.SetDisplayName("AgarIo Service");
     configurator.SetDescription("Serves AgarIo Game");
     configurator.UseNLog();
 }
Exemple #41
0
 private static void Configure(HostConfigurator config)
 {
     config.UseAutofacContainer(InitializeContainer());
     config.SetServiceName("TFSEventListener");
     config.SetDisplayName("TFS Event Listener");
     config.Service<EventListener>(s =>
     {
         s.ConstructUsingAutofacContainer();
         s.WhenStarted((service, control) => service.Start());
         s.WhenStopped((service, control) => service.Stop());
     });
 }
 protected override void Configure(HostConfigurator hostConfigurator)
 {
     string svcBusConnection = CloudConfigurationManager.GetSetting("ServiceBusConnectionString_Subscriber");
     var queueName = CloudConfigurationManager.GetSetting("ReceivingQueueName");
     var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("MessageStorageConnectionString"));
     
     hostConfigurator.Service(s => new Subscriber(svcBusConnection, queueName, storageAccount), x =>
     {
         x.BeforeStartingService(ctxt => _logger.Info("Starting Subscriber service"));
         x.AfterStoppingService(ctxt => _logger.Info("Subscriber Service stopped"));
     });
 }
        static void Configurator(HostConfigurator configurator)
        {
            configurator.Service<ServiceHost>(settings =>
                                                  {
                                                      settings.ConstructUsing(p=> new ServiceHost());
                                                      settings.WhenStarted(p=>p.Start());
                                                      settings.WhenStopped(p=>p.Stop());
                                                  });

            configurator.SetServiceName("Listener");
            configurator.SetDisplayName("DeployNowListener");
            configurator.RunAsLocalSystem();
            configurator.StartAutomaticallyDelayed();
        }
Exemple #44
0
        private static void ConfigureService(HostConfigurator x)
        {
            var builder = new ContainerBuilder();
            builder.RegisterModule<MainModule>();
            var container = builder.Build();

            x.Service<IWeatherService>(s =>
                                       {
                                           s.ConstructUsing(_ => container.Resolve<IWeatherService>());
                                           s.WhenStarted(srv => srv.Start());
                                           s.WhenStopped(srv => StopService(srv, container));
                                       });

            x.SetServiceName(Weatherservice);
            x.SetDisplayName(Weatherservice);
        }
Exemple #45
0
        private void CreateServiceConfiguration(HostConfigurator x)
        {
            

            var config = container.Resolve<RendezvousConfiguration>();

            x.Service<IRendezvousService>(s =>
                                          {
                                              s.ConstructUsing(_ => CreateServiceInstance());
                                              s.WhenStarted(rs => rs.Start());
                                              s.WhenStopped(ServiceStop);
                                          });
            x.RunAsPrompt();
            x.SetServiceName(config.ServiceName);
            x.SetDisplayName(config.ServiceName);
            x.SetDescription($"{config.ServiceName} Service");
        }
        public WindowsServiceHost(HostEnvironment environment, HostSettings settings, ServiceHandle serviceHandle, HostConfigurator configurator)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");
            if (serviceHandle == null)
                throw new ArgumentNullException("serviceHandle");

            _settings = settings;
            _serviceHandle = serviceHandle;
            _environment = environment;
            _configurator = configurator;

            CanPauseAndContinue = settings.CanPauseAndContinue;
            CanShutdown = settings.CanShutdown;
            CanHandleSessionChangeEvent = settings.CanSessionChanged;
            ServiceName = _settings.ServiceName;
        }
Exemple #47
0
        void ConfigureHost(HostConfigurator x)
        {
            x.UseSerilog(_container.Resolve<ILogger>());
            x.Service<PapercutServerService>(
                s =>
                {
                    s.ConstructUsing(serviceFactory => _container.Resolve<PapercutServerService>());
                    s.WhenStarted(tc => tc.Start());
                    s.WhenStopped(tc => tc.Stop());
                    s.WhenShutdown(ts => _container.Dispose());
                });

            x.RunAsLocalSystem();

            x.SetDescription("Papercut SMTP Backend Service");
            x.SetDisplayName("Papercut SMTP Service");
            x.SetServiceName("PapercutServerService");
        }
Exemple #48
0
        /// <summary>
        /// Configures the specified host configurator.
        /// </summary>
        /// <param name="hostConfigurator">The host configurator.</param>
        protected override void Configure(HostConfigurator hostConfigurator)
        {
            var configuration = new Configuration
            {
                EventHubConnectionString = CloudConfigurationManager.GetSetting(nameof(Configuration.EventHubConnectionString)),
                StorageConnectionString = CloudConfigurationManager.GetSetting(nameof(Configuration.StorageConnectionString)),
                EventHubName = CloudConfigurationManager.GetSetting(nameof(Configuration.EventHubName)),
                Email = CloudConfigurationManager.GetSetting(nameof(Configuration.Email)),
                Identifier = RoleEnvironment.IsAvailable ? RoleEnvironment.CurrentRoleInstance.Id : Environment.MachineName
            };

            _log.InfoFormat("Service Configuration: {0}", JsonConvert.SerializeObject(configuration));

            hostConfigurator.Service(settings => new EventPubService(configuration), x =>
            {
                x.BeforeStartingService(context => _log.Info("Service is being started"));
                x.AfterStoppingService(context => _log.Info("Service has stopped"));
            });
        }
 public override void Configure(HostConfigurator conf)
 {
     conf.RunAsNetworkService();
 }
 public LinuxHostEnvironmentBuilderImpl(HostConfigurator configurator, IDictionary<string, object> arguments)
 {
     _configurator = configurator;
     _arguments = arguments;
 }
 public void ApplyTo(HostConfigurator configurator)
 {
     configurator.SetServiceName(_serviceName);
 }
 public void ApplyTo(HostConfigurator configurator)
 {
     _callback(_value);
 }
 public SpWindowsHostEnvironment(HostConfigurator configurator)
 {
     _hostConfigurator = configurator;
     _environment=new WindowsHostEnvironment(configurator);
 }
 public override void Configure(HostConfigurator conf)
 {
     conf.RunAsLocalSystem();
 }
 public void ApplyTo(HostConfigurator configurator)
 {
     configurator.SetDisplayName(_name);
 }
 public LinuxHostEnvironmentImpl(HostConfigurator configurator, IDictionary<string, object> arguments)
 {
     _configurator = configurator;
     _arguments = arguments;
     _logWriter = HostLogger.Get<LinuxHostEnvironmentImpl>();
 }
Exemple #57
0
 public void ApplyTo(HostConfigurator configurator)
 {
     configurator.SetInstanceName(_instanceName);
 }
Exemple #58
0
 public void ApplyTo(HostConfigurator configurator)
 {
     configurator.AddConfigurator(new UnknownCommandLineOptionHostConfigurator(_text));
 }
		public CommandLineParameterBuilder(HostConfigurator configurator)
		{
			_configurator = configurator;
			_parameters = new Dictionary<string, object>();
		}
 public WindowsHostEnvironmentBuilder(HostConfigurator configurator)
 {
     _hostConfigurator = configurator;
 }