/// <summary> /// Get an instance of Application /// </summary> /// <param name="parentLogger">Logger implementation</param> public Application(ILoggerInterface parentLogger) { NewRelic.Api.Agent.NewRelic.SetApplicationName("IisChef"); NewRelicAgentExtensions.AddCustomParameter("server", Environment.MachineName); NewRelicAgentExtensions.AddCustomParameter("user", Environment.UserName); BindingRedirectHandler.DoBindingRedirects(AppDomain.CurrentDomain); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; // Check current account var identity = WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); parentLogger.LogInfo(false, $"Chef app started with identity '{identity.Name}'"); if (!principal.IsInRole(WindowsBuiltInRole.Administrator)) { parentLogger.LogError("Not running under full admin privileges."); if (Debugger.IsAttached) { throw new Exception("You must run the deployer with full privileges."); } } // Use the parent logger, at least until we can build a file based one... this.Logger = parentLogger; }
/// <summary> /// What a loop really does /// </summary> protected void LoopImplementation() { // This ensures that settings and other // stuff is reloaded on every loop. BindingRedirectHandler.DoBindingRedirects(AppDomain.CurrentDomain); var app = this.Console ? ConsoleUtils.GetApplicationForConsole() : new Application(this.Logger); app.Initialize(this.SettingsFile); app.RunServiceLoop(); app.RunDeploymentLoop(); }