public AppService() { CoreLoggerFactory.SetFactoryMethod(name => new NlogLoggerWrapper(name)); PluginLibrary = new PluginLibrary(); FigureCollection = new FigureCollection(); WindowManager = new WindowManager(); FigureStorage = new PersistanceModel(this); Settings = new SettingsModel(); }
static void Main(string[] args) { Console.Title = "Automatica.Core.Watchdog"; Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.Console() .MinimumLevel.Verbose() .Filter.ByExcluding(Matching.FromSource("Microsoft")) .CreateLogger(); var logger = CoreLoggerFactory.GetLogger("Watchdog"); logger.LogInformation($"Starting WatchDog...Version {ServerInfo.GetServerVersion()}, Datetime {ServerInfo.StartupTime}"); var fi = new FileInfo(Assembly.GetEntryAssembly().Location); var appName = Path.Combine(fi.DirectoryName, ServerInfo.ServerExecutable); //logger.LogInformation($"Getting all processes by name {ServerInfo.ServerExecutable}..."); //var processes = Process.GetProcessesByName(ServerInfo.ServerExecutable); //logger.LogInformation($"Getting all processes by name {ServerInfo.ServerExecutable}...done"); //foreach (var process in processes) //{ // logger.LogInformation($"Kill {process.ProcessName} - {process.MainWindowTitle}..."); // process.Kill(); //} var tmpPath = Path.Combine(ServerInfo.GetTempPath(), $"Automatica.Core.Update"); if (Directory.Exists(tmpPath)) { Directory.Delete(tmpPath, true); } if (File.Exists(Path.Combine(ServerInfo.GetTempPath(), ServerInfo.UpdateFileName))) { File.Delete(Path.Combine(ServerInfo.GetTempPath(), ServerInfo.UpdateFileName)); } ProcessStartInfo processInfo; if (!File.Exists(appName)) { if (!File.Exists(appName + ".dll")) { logger.LogError($"Could not fine {appName} or {appName}.dll - exiting startup..."); return; } logger.LogInformation($"Starting with dotnet {appName}.dll"); processInfo = new ProcessStartInfo("dotnet", appName + ".dll"); } else { processInfo = new ProcessStartInfo(appName); } processInfo.WorkingDirectory = Environment.CurrentDirectory; Process process = null; try { while (true) { logger.LogInformation($"Starting {appName}"); process = Process.Start(processInfo); process.WaitForExit(); var exitCode = process.ExitCode; logger.LogInformation($"{appName} stopped with exit code {exitCode}"); if (PrepareUpdateIfExists(logger)) { Environment.Exit(2); //restart return; } process = null; Thread.Sleep(500); } } catch (TaskCanceledException) { process?.Kill(); } Console.ReadLine(); //cancelToken.Cancel(); }
internal BaseDataRecorderWriter(string recorderName, INodeInstanceCache nodeCache, IDispatcher dispatcher) { Logger = CoreLoggerFactory.GetLogger(recorderName); _nodeCache = nodeCache; Dispatcher = dispatcher; }
public PluginInstaller() { _logger = CoreLoggerFactory.GetLogger("PluginInstaller"); }
public CoreLoggerFactoryTests() { _factory = Substitute.For <ILoggerFactory>(); _factoryCore = new CoreLoggerFactory(_factory); }