Example #1
0
        private static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(DirectoryExtensions.GetCurrentDirectory())
                          .AddJsonFile("settings.json", optional: true, reloadOnChange: true);
            var configuration = builder.Build();

            var services = new ServiceCollection()
                           .AddSchedulerServices(configuration)
                           .BuildServiceProvider();

            LoggerExtensions.CreateLogger("Scheduler");
            HostFactory.Run(config =>
            {
                config.Service <SchedulerHostedService>(s =>
                {
                    s.ConstructUsing(service => services.GetService <SchedulerHostedService>());
                    s.WhenStarted(async service => await service.StartAsync(CancellationToken.None));
                    s.WhenStopped(async service => await service.StopAsync(CancellationToken.None));
                });

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

                config.SetDescription("Scheduler (Topshelf Service)");
                config.SetDisplayName("HiQoScheduler");
                config.SetServiceName("HiQoScheduler");
            });
        }
 public RedisErrorLog(IOptions <ElmahOptions> options)
 {
     LoggerExtensions.CreateLogger("Elmah");
     _redisClient = new ElmahRedisClient(options.Value.ConnectionString);
 }