Files
Clint Dovholuk 2f7e53f02c Allow registry overrides.conflict.free (#992)
* feat: bump dependencies (NuGet 8 -> 10, NLog 5 -> 6)

* feat: shared IPC data structures for policy state

* feat: registry policy reader with WMI watcher

* feat: monitor service policy enforcement, maintenance window, deferred install

* feat: UI policy state propagation, locks, deferred-install + sentinel UX fix

* feat: ADMX/ADML templates, admin guide, helper script, test runbook

* chore: build tooling, MSI SHA256, version bump, release notes

* more reworking around the adml/admx/md

* build and upload ADMX/ADML admin templates zip

* updates from looking at / testing GPO UI

* missed the prepare-for-tests ps1

* add boms to all ps1's just in case

* update test-run for more vebosity to allow humans to understand

* more updates to release notes

* Fix alignment on "from" label for maintenance window

* Remove arrow pointing to task bar

* Remove unused selection changed stub

* Ensure logical hour value is passed to maintenance window start/end

* Fix invalid URL error not showing - ensure maintenance start/end time errors return correctly

Change variable names

* reworking new-upcoming-releasenotes

* publish admin templates zip + sha256 sidecar to GitHub release, update release note

* add tatooing words

* reword clamping words

---------

Co-authored-by: Christopher Britton <christopher.l.britton@outlook.com>
2026-05-06 09:14:57 -04:00

105 lines
3.8 KiB
C#

/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.IO;
using System.Reflection;
using System.ServiceProcess;
using NLog;
using NLog.Config;
using NLog.Targets;
namespace ZitiUpdateService {
static class Program {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main() {
var asm = Assembly.GetExecutingAssembly();
var logname = asm.GetName().Name;
var curdir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string nlogFile = Path.Combine(curdir, $"{logname}-log.config");
bool byFile = false;
if (File.Exists(nlogFile)) {
LogManager.Configuration = new XmlLoggingConfiguration(nlogFile);
byFile = true;
} else {
var config = new LoggingConfiguration();
// Targets where to log to: File and Console
var logfile = new FileTarget("logfile") {
FileName = $"logs\\ZitiMonitorService\\{logname}.log",
ArchiveEvery = FileArchivePeriod.Day,
ArchiveSuffixFormat = "_{0:00}",
MaxArchiveFiles = 7,
AutoFlush = true,
Layout = "[${date:universalTime=true:format=yyyy-MM-ddTHH:mm:ss.fff}Z] ${level:uppercase=true:padding=5}\t${logger}\t${message}\t${exception:format=tostring}",
};
var logconsole = new ConsoleTarget("logconsole");
// Rules for mapping loggers to targets
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logconsole);
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);
// Apply config
LogManager.Configuration = config;
}
Logger.Info("========================= ziti-monitor started =========================");
Logger.Info("logger initialized");
Logger.Info(" - version : {0}", asm.GetName().Version.ToString());
Logger.Info(" - using file: {0}", byFile);
Logger.Info(" - file: {0}", nlogFile);
Logger.Info("========================================================================");
UpdateService updateSvc = new UpdateService();
updateSvc.AutoLog = true;
try {
#if DEBUG
bool nosvc = true;
//bool nosvc = false;
if (nosvc) {
Logger.Info(" - RUNNING AS DEBUG");
updateSvc.Debug();
updateSvc.WaitForCompletion();
Logger.Info(" - RUNNING AS DEBUG COMPLETE");
} else {
ServiceBase[] ServicesToRun = new ServiceBase[]
{
updateSvc
};
Logger.Info("RUNNING AS DEBUG SERVICE");
ServiceBase.Run(ServicesToRun);
}
#else
ServiceBase[] ServicesToRun = new ServiceBase[]
{
updateSvc
};
ServiceBase.Run(ServicesToRun);
#endif
} catch (Exception e) {
Logger.Error("Unexpected exception: {0}", e);
}
}
}
}