static void Main(string[] args) { var options = new SchedulerOptions { Url = ConfigurationManager.AppSettings["Url"], InputFile = ConfigurationManager.AppSettings["InputFile"], LoggingFolder = ConfigurationManager.AppSettings["LoggingFolder"], }; var container = AutofacContainer.Configure(options.LoggingFolder); GlobalConfiguration.Configuration.UseAutofacActivator(container); var _logger = container.Resolve <Interfaces.ILogger>(); HostFactory.Run(c => { c.UseAutofacContainer(container); c.Service <Scheduler>(callback: s => { s.ConstructUsingAutofacContainer(); s.WhenStarted((service, control) => { _logger.Information("Service started..."); return(service.Start(options)); }); s.WhenStopped((service, control) => service.Stop()); }); c.SetDisplayName("MailSchedulerService"); c.SetDescription("dupa123"); c.StartAutomatically(); c.RunAsLocalService(); }); }
public bool Start(SchedulerOptions options) { try { _service.Init(options.InputFile); webApp = WebApp.Start <Startup>(options.Url); //processmailqueue return(true); } catch (Exception ex) { _logger.Error($"Topshelf starting occured errors:{ex.ToString()}"); return(false); } }
public bool Start(SchedulerOptions options) { try { _service.Init(options.InputFile); webApp = WebApp.Start <Startup>(options.Url); RecurringJob.AddOrUpdate( () => _service.ProcessMailQueue(), Cron.Minutely() ); return(true); } catch (Exception ex) { _logger.Error($"Topshelf starting occured errors:{ex.ToString()}"); return(false); } }