Exemple #1
0
        /// <summary>
        /// Однократный ручной запуск заданий.
        /// </summary>
        private static int RunJobsManually
        (
            string[] args
        )
        {
            string selectedJobName = null;

            if (args.Length > 1)
            {
                selectedJobName = args[1];
            }

            HostLogger.UseLogger
            (
                new NLogLogWriterFactory.NLogHostLoggerConfigurator()
            );

            try
            {
                JobController.RunJobsManually(selectedJobName);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
                return(1);
            }

            return(0);
        }
Exemple #2
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));
 }
Exemple #3
0
        public void Create(ServiceBuilderFactory serviceBuilderFactory, HostSettings settings,
                           HostLoggerConfigurator loggerConfigurator)
        {
            AppDomain.CurrentDomain.UnhandledException += CatchUnhandledException;

            HostLogger.UseLogger(loggerConfigurator);

            ServiceBuilder serviceBuilder = serviceBuilderFactory(settings);

            _serviceHandle = serviceBuilder.Build(settings);
        }
Exemple #4
0
        public void InitDatabase()
        {
            DbInstaller.Install();

            _logger = new LoggerConfiguration()
                      .MinimumLevel.Debug()
                      .WriteTo.File("./log.txt").CreateLogger();
            HostLogger.UseLogger(new SerilogLogWriterFactory.SerilogHostLoggerConfigurator(_logger));

            mock = new Mock <IWebApiConnector>();
            mock.Setup(api => api.FindProjectWorkerByFaceId("2", GlobalConfig.ProjectCode)).ReturnsAsync("2222222");
            mock.Setup(api => api.CheckIn(GlobalConfig.ProjectCode, "2222222", new DateTime(2018, 1, 13, 8, 11, 30), "gate01")).ReturnsAsync(true);
            mock.Setup(api => api.CheckIn(GlobalConfig.ProjectCode, "2222222", new DateTime(2018, 1, 13, 12, 11, 30), "gate01")).ReturnsAsync(false);
            mock.Setup(api => api.CheckOut(GlobalConfig.ProjectCode, "2222222", new DateTime(2018, 1, 13, 10, 11, 30))).ReturnsAsync(true);
            mock.Setup(api => api.CheckOut(GlobalConfig.ProjectCode, "2222222", new DateTime(2018, 1, 13, 14, 11, 30))).ReturnsAsync(false);
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            string homeDir        = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            string programHomeDir = Path.Combine(homeDir, ".keminet");
            string logDir         = Path.Combine(programHomeDir, "logs");

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.File($"{logDir}/myapp.txt", rollingInterval: RollingInterval.Day)
                         .CreateLogger();

            Log.Information("Hello, world!");

            HostLogger.UseLogger(new SerilogLogWriterFactory.SerilogHostLoggerConfigurator(Log.Logger));
            HostFactory.Run(host =>
            {
                host.UseLinuxIfAvailable();
                host.Service <MainService>(service =>
                {
                    host.SetServiceName("Kemi.NET");
                    host.SetDisplayName("Kemi Process Manager");
                    const string desc = "This service is a process manager for apps. Kill-Execute-Manage-Inspect";
                    host.SetDescription(desc);
                    host.StartAutomatically();

                    service.ConstructUsing(name => new MainService());
                    service.WhenStarted(tc => tc.Start());
                    service.WhenStopped(tc => tc.Stop());
                });
                host.UseSerilog();

                try
                {
                    host.RunAsLocalSystem();
                }
                catch (Exception ex)
                {
                    Log.Error($"Error Starting up Service. Reason: {ex.Message}");
                }
            });
        }
        static void Main()
        {
            Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Log4NetConfig));
            HostLogger.UseLogger(new Log4NetLogWriterFactory.Log4NetLoggerConfigurator(Log4NetConfig));

            HostFactory.Run(x =>
            {
                x.Service <Service>(s =>
                {
                    s.ConstructUsing(() => new Service());
                    s.WhenStarted(service => service.Start());
                    s.WhenStopped(service => service.Stop());
                });

                x.RunAsLocalSystem();
                x.SetDescription("SubscriptionConventions example service.");
                x.SetServiceName("SubscriptionConventionsExampleService");
                x.SetDisplayName("SubscriptionConventions Example Service");
            });
        }
        public override void Start()
        {
            // Wires up the internal topshelf logger to the same logger that wave is configured to use
            HostLogger.UseLogger(new WaveLogWriterConfigurator(this.ConfigurationContext.Logger));

            HostFactory.Run(x =>
            {
                switch (this.ConfigurationContext.GetUserType())
                {
                case Configuration.RunAs.LocalService:
                    x.RunAsLocalService();
                    break;

                case Configuration.RunAs.LocalSystem:
                    x.RunAsLocalSystem();
                    break;

                case Configuration.RunAs.NetworkService:
                    x.RunAsNetworkService();
                    break;

                case Configuration.RunAs.User:
                    x.RunAs(this.ConfigurationContext.GetUsername(), this.ConfigurationContext.GetPassword());
                    break;
                }

                x.SetDescription(this.ConfigurationContext.GetDescription());
                x.SetDisplayName(this.ConfigurationContext.GetDisplayName());
                x.SetServiceName(this.ConfigurationContext.GetServiceName());

                x.Service <BusHost>(sc =>
                {
                    sc.ConstructUsing(() => this);
                    sc.WhenStarted(s => base.Start());
                    sc.WhenStopped(s => base.Stop());
                });
            });
        }
 public static void Use(LogFactory factory)
 {
     HostLogger.UseLogger(new NLogHostLoggerConfigurator(factory));
 }
 public static void Use()
 {
     HostLogger.UseLogger(new NLogHostLoggerConfigurator());
 }
Exemple #10
0
 /// <summary>
 /// Configures Topshelf to use Microsoft extensions for logging, using a <see cref="ILoggerFactory" /> instance to derive its loggers.
 /// </summary>
 /// <param name="configurator">The configurator.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public static void UseLoggingExtensions(this HostConfigurator configurator, ILoggerFactory loggerFactory)
 {
     HostLogger.UseLogger(new LoggingExtensionsLogWriterFactory.LoggingExtensionsHostLoggerConfigurator(loggerFactory));
 }
Exemple #11
0
 internal static void Use()
 {
     HostLogger.UseLogger(new CommonLoggingConfigurator());
 }
 public AzureBlobBuilderExtensionShould()
 {
     HostLogger.UseLogger(new TraceHostLoggerConfigurator());
 }
Exemple #13
0
 public static void Use(string file)
 {
     HostLogger.UseLogger(new Log4NetLoggerConfigurator(file));
 }
Exemple #14
0
 public static void Use()
 {
     HostLogger.UseLogger(new Log4NetLoggerConfigurator(null));
 }
 /// <summary>
 ///   Specify that you want to use the NLog logging framework.
 /// </summary>
 /// <param name="configurator"> Optional service bus configurator </param>
 /// <param name="factory"> Required log-producing factory from NLog </param>
 public static void UseNLog(this HostConfigurator configurator, LogFactory factory)
 {
     HostLogger.UseLogger(new NLogLogWriterFactory(factory));
 }
Exemple #16
0
 public static void UseEventLog(this HostConfigurator configurator, BottleServiceConfiguration settings)
 {
     HostLogger.UseLogger(new EventLogFactoryConfigurator(settings));
 }
Exemple #17
0
 public static void UseLibLog(this HostConfigurator configurator)
 {
     HostLogger.UseLogger(new LibLogLoggerConfigurator());
 }
Exemple #18
0
 /// <summary>
 ///     Specify that you want to use the Serilog logging engine.
 /// </summary>
 /// <param name="configurator"></param>
 public static void UseSerilog(this HostConfigurator configurator)
 {
     HostLogger.UseLogger(new SerilogHostLoggerConfigurator());
 }