diff --git a/Installer/ZitiDesktopEdge.aip b/Installer/ZitiDesktopEdge.aip index a6cccd04..0f1cfe56 100644 --- a/Installer/ZitiDesktopEdge.aip +++ b/Installer/ZitiDesktopEdge.aip @@ -82,6 +82,7 @@ + diff --git a/ZitiUpdateService/NLog.config b/ZitiUpdateService/NLog.config deleted file mode 100644 index 4115bea8..00000000 --- a/ZitiUpdateService/NLog.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/ZitiUpdateService/Program.cs b/ZitiUpdateService/Program.cs index 6c482650..47b17a83 100644 --- a/ZitiUpdateService/Program.cs +++ b/ZitiUpdateService/Program.cs @@ -1,4 +1,6 @@ using System; +using System.IO; +using System.Reflection; using System.ServiceProcess; using NLog; using NLog.Config; @@ -13,26 +15,33 @@ namespace ZitiUpdateService { /// static void Main() { //Environment.SetEnvironmentVariable("ZITI_EXTENDED_DEBUG", "true"); + var curdir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string nlogFile = Path.Combine(curdir, "ziti-monitor-log.config"); - var config = new LoggingConfiguration(); - var logname = "ziti-montior"; - // Targets where to log to: File and Console - var logfile = new FileTarget("logfile") { - FileName = $"{logname}.log", - ArchiveEvery = FileArchivePeriod.Day, - ArchiveNumbering = ArchiveNumberingMode.Rolling, - MaxArchiveFiles = 7, - //ArchiveAboveSize = 10000, + if (File.Exists(nlogFile)) { + LogManager.Configuration = new XmlLoggingConfiguration(nlogFile); + } else { + var config = new LoggingConfiguration(); + var logname = "ziti-montior"; + // Targets where to log to: File and Console + var logfile = new FileTarget("logfile") { + FileName = $"{logname}.log", + ArchiveEvery = FileArchivePeriod.Day, + ArchiveNumbering = ArchiveNumberingMode.Rolling, + MaxArchiveFiles = 7, + Layout = "${longdate}|${level:uppercase=true:padding=5}|${logger}|${message}", + //ArchiveAboveSize = 10000, }; - var logconsole = new ConsoleTarget("logconsole"); + var logconsole = new ConsoleTarget("logconsole"); - // Rules for mapping loggers to targets - config.AddRule(LogLevel.Info, LogLevel.Fatal, logconsole); - config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile); - - // Apply config - LogManager.Configuration = config; + // Rules for mapping loggers to targets + config.AddRule(LogLevel.Info, LogLevel.Fatal, logconsole); + config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile); + // Apply config + LogManager.Configuration = config; + } + Logger.Info("service started - logger initialized"); UpdateService updateSvc = new UpdateService(); #if DEBUG diff --git a/ZitiUpdateService/UpdateCheckers.cs b/ZitiUpdateService/UpdateCheckers.cs index d478cff9..34c265b1 100644 --- a/ZitiUpdateService/UpdateCheckers.cs +++ b/ZitiUpdateService/UpdateCheckers.cs @@ -50,6 +50,9 @@ namespace ZitiUpdateService { } else if (compare > 0) { Logger.Info("the version installed is newer than the released version"); return false; + } else { + Logger.Debug("current version {0} is the same as the latest release {0}", current, published); + return false; } JArray assets = JArray.Parse(json.Property("assets").Value.ToString()); foreach (JObject asset in assets.Children()) { diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs index 2df6928c..637a80b1 100644 --- a/ZitiUpdateService/UpdateService.cs +++ b/ZitiUpdateService/UpdateService.cs @@ -76,15 +76,6 @@ namespace ZitiUpdateService { } private void SetupServiceWatchers() { - Logger.Info("setting up watches"); - - try { - svc.Connect(); - } catch { - //svc.Reconnect(); - } - - //svc.WaitForConnection(); var updateTimerInterval = ConfigurationManager.AppSettings.Get("UpdateTimer"); var upInt = TimeSpan.Zero; @@ -92,8 +83,6 @@ namespace ZitiUpdateService { upInt = new TimeSpan(0, 1, 0); } - Logger.Info("Ziti Update Setting Up Watchers"); - _updateTimer = new System.Timers.Timer(); _updateTimer.Elapsed += CheckUpdate; _updateTimer.Interval = upInt.TotalMilliseconds; @@ -101,13 +90,21 @@ namespace ZitiUpdateService { _updateTimer.Start(); Logger.Info("Version Checker is running"); CheckUpdate(null, null); //check immediately + + try { + svc.Connect(); + } catch { + svc.Reconnect(); + } + + svc.WaitForConnection(); } private void CheckUpdate(object sender, ElapsedEventArgs e) { if (inUpdateCheck) return; inUpdateCheck = true; //simple semaphone try { - Logger.Info("checking for update"); + Logger.Debug("checking for update"); var updateUrl = ConfigurationManager.AppSettings.Get("UpdateUrl"); if (string.IsNullOrEmpty(updateUrl)) { updateUrl = "https://api.github.com/repos/openziti/desktop-edge-win/releases/latest"; diff --git a/ZitiUpdateService/ZitiUpdateService.csproj b/ZitiUpdateService/ZitiUpdateService.csproj index 9b676c36..52a43b79 100644 --- a/ZitiUpdateService/ZitiUpdateService.csproj +++ b/ZitiUpdateService/ZitiUpdateService.csproj @@ -125,6 +125,9 @@ Always + + Always + diff --git a/ZitiUpdateService/ziti-monitor-log.config b/ZitiUpdateService/ziti-monitor-log.config new file mode 100644 index 00000000..21d526a1 --- /dev/null +++ b/ZitiUpdateService/ziti-monitor-log.config @@ -0,0 +1,20 @@ + + + + + + + + + + + + + diff --git a/version b/version index 3a3cd8cc..1892b926 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.3.1 +1.3.2