Exemplo n.º 1
0
        /// <summary>
        /// Ensures valid /home/site/deployments/settings.xml is loaded, deletes
        /// corrupt settings.xml file
        /// </summary>
        /// <param name="environment">
        /// IEnvironment object that maintains paths used by kudu
        /// </param>
        internal static void EnsureValidDeploymentXmlSettings(IEnvironment environment)
        {
            var path = GetSettingsPath(environment);

            if (!FileSystemHelpers.FileExists(path))
            {
                return;
            }
            try
            {
                var settings = new DeploymentSettingsManager(new XmlSettings.Settings(path));
                settings.GetValue(SettingsKeys.TraceLevel);
            }
            catch (Exception ex)
            {
                DateTime lastWriteTimeUtc = DateTime.MinValue;
                OperationManager.SafeExecute(() => lastWriteTimeUtc = File.GetLastWriteTimeUtc(path));
                // trace initialization error
                KuduEventSource.Log.KuduException(
                    ServerConfiguration.GetApplicationName(),
                    "Startup.cs",
                    string.Empty,
                    string.Empty,
                    string.Format("Invalid '{0}' is detected and deleted.  Last updated time was {1}.", path,
                                  lastWriteTimeUtc),
                    ex.ToString());
                File.Delete(path);
            }
        }
Exemplo n.º 2
0
        internal static void TraceShutdown(IEnvironment environment, IDeploymentSettingsManager settings)
        {
            ITracer tracer  = GetTracerWithoutContext(environment, settings);
            var     attribs = new Dictionary <string, string>();

            // Add an attribute containing the process, AppDomain and Thread ids to help debugging
            attribs.Add("pid", String.Format("{0},{1},{2}",
                                             Process.GetCurrentProcess().Id,
                                             AppDomain.CurrentDomain.Id.ToString(),
                                             Thread.CurrentThread.ManagedThreadId));

            attribs.Add("uptime", TraceMiddleware.UpTime.ToString());

            attribs.Add("lastrequesttime", TraceMiddleware.LastRequestTime.ToString());

            tracer.Trace(XmlTracer.ProcessShutdownTrace, attribs);

            OperationManager.SafeExecute(() =>
            {
                KuduEventSource.Log.GenericEvent(
                    ServerConfiguration.GetApplicationName(),
                    string.Format("Shutdown pid:{0}, domain:{1}", Process.GetCurrentProcess().Id,
                                  AppDomain.CurrentDomain.Id),
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty);
            });
        }