private void _settings_Changed(object sender, EventArgs e) { log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(_settings.Combine("log4net.config"))); Apps.Settings = _settings.Renew <Settings>(); _log.InfoFormat("settings: {0}", JsonMapper.ToJson(Apps.Settings)); _log.Info(String.Format("Settings Changed {0} at {1}.", ServiceName, DateTime.Now)); if (isStarting) { foreach (var worker in workers) { worker.Cancel(); } foreach (var task in Apps.Settings.Tasks) { var worker = new TaskWorker(task); workers.Add(worker); } } _log.Info(String.Format("Restarting {0} at {1}.", ServiceName, DateTime.Now)); }
protected override void OnStart(string[] args) { isStarting = true; if (Environment.UserInteractive) { _log.Info("Press any key to stop the program."); } foreach (var task in Apps.Settings.Tasks) { var worker = new TaskWorker(task); workers.Add(worker); } _log.Info(String.Format("Starting {0} at {1}.", ServiceName, DateTime.Now)); }
private void _settings_Changed(object sender, EventArgs e) { log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(_settings.Combine("log4net.config"))); Apps.Settings = _settings.Renew<Settings>(); _log.InfoFormat("settings: {0}", JsonMapper.ToJson(Apps.Settings)); _log.Info(String.Format("Settings Changed {0} at {1}.", ServiceName, DateTime.Now)); if (isStarting) { foreach (var worker in workers) worker.Cancel(); foreach (var task in Apps.Settings.Tasks) { var worker = new TaskWorker(task); workers.Add(worker); } } _log.Info(String.Format("Restarting {0} at {1}.", ServiceName, DateTime.Now)); }