Exemplo n.º 1
0
        public ActionResult <string> Ping()
        {
            var envInfo = cubesEnvironment.GetEnvironmentInformation();
            var proc    = Process.GetCurrentProcess();
            var info    = new
            {
                ProcID           = proc.Id,
                ProcessName      = proc.ProcessName,
                Executable       = Path.GetFileName(proc.MainModule.FileName),
                Assembly         = Assembly.GetEntryAssembly().GetName().Name,
                WorkingFolder    = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
                Machine          = proc.MachineName,
                Hostname         = envInfo.Hostname,
                KernelVersion    = envInfo.BuildVersion,
                GitHash          = envInfo.GitHash,
                Build            = envInfo.IsDebug ? "DEBUG" : "RELEASE",
                BuildTime        = envInfo.BuildDateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                LiveSince        = envInfo.LiveSince.ToString("yyyy-MM-dd HH:mm:ss"),
                ServerTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                WorkingSet       = Math.Round(proc.WorkingSet64 / 1024M / 1024M, 2),
                PeakWorkingSet   = Math.Round(proc.PeakWorkingSet64 / 1024M / 1024M, 2),
                Threads          = proc.Threads.Count,
                LoadedAssemblies = cubesEnvironment.GetLoadedAssemblies(),
                ConfiguredApps   = cubesEnvironment.GetApplications(),
                ActivatedApps    = cubesEnvironment.GetActivatedApplications().Select(app => app.GetType().Name)
            };

            return(Ok(info));
        }
Exemplo n.º 2
0
        public static IConfigurationBuilder AddCubesConfigurationProvider(this IConfigurationBuilder configuration,
                                                                          ICubesEnvironment cubes)
        {
            const string section     = CubesConstants.Configuration_Section;
            var          cubesConfig = new Dictionary <string, string>
            {
                { $"{section}:Version", cubes.GetEnvironmentInformation().FullVersion },
                { $"{section}:RootFolder", cubes.GetRootFolder() },
                { $"{section}:AdminPath", cubes.GetAdminPath() },
                { $"{section}:ContentFolder", cubes.GetFolder(CubesFolderKind.Content) },
                { $"{section}:LibrariesFolder", cubes.GetFolder(CubesFolderKind.Libraries) },
                { $"{section}:LogsFolder", cubes.GetFolder(CubesFolderKind.Logs) },
                { $"{section}:ConfigFolder", cubes.GetConfigurationFolder() },
                { $"{section}:StorageFolder", cubes.GetStorageFolder() },
                { $"{section}:TempFolder", cubes.GetFolder(CubesFolderKind.Temp) },
                { $"{section}:WebRootFolder", cubes.GetFolder(CubesFolderKind.WebRoot) },
                { $"{section}:BinariesFolder", cubes.GetBinariesFolder() },
            };
            var swaggerFiles = cubes
                               .GetSwaggerXmlFiles()
                               .Select((f, i) => new KeyValuePair <string, string>($"{section}:SwaggerXMLFiles:{i}", f))
                               .ToList();

            foreach (var item in swaggerFiles)
            {
                cubesConfig.Add(item.Key, item.Value);
            }

            configuration.AddInMemoryCollection(cubesConfig);
            return(configuration);
        }
Exemplo n.º 3
0
        public ActionResult <string> Ping()
        {
            var envInfo = cubesEnvironment.GetEnvironmentInformation();
            var proc    = Process.GetCurrentProcess();

            if (proc == null || proc.MainModule == null)
            {
                throw new Exception("Could not get Cubes process information");
            }
            var asm = Assembly.GetEntryAssembly();

            if (asm == null)
            {
                throw new Exception("Could not get Cubes entry assembly information");
            }

            var info = new
            {
                ProcID = proc.Id,
                proc.ProcessName,
                Executable    = Path.GetFileName(proc.MainModule.FileName),
                Assembly      = asm.GetName().Name,
                WorkingFolder = Path.GetDirectoryName(asm.Location),
                Machine       = proc.MachineName,
                envInfo.Hostname,
                CoreVersion = envInfo.BuildVersion,
                Build       = envInfo.IsDebug ? "DEBUG" : "RELEASE",
                envInfo.BuildInformation,
                LiveSince        = envInfo.LiveSince.ToString("yyyy-MM-dd HH:mm:ss"),
                ServerTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                WorkingSet       = Math.Round(proc.WorkingSet64 / 1024M / 1024M, 2),
                PeakWorkingSet   = Math.Round(proc.PeakWorkingSet64 / 1024M / 1024M, 2),
                Threads          = proc.Threads.Count,
                LoadedAssemblies = cubesEnvironment.GetLoadedAssemblies(),
                ConfiguredApps   = cubesEnvironment.GetLoadedeApplications(),
                ActivatedApps    = cubesEnvironment.GetApplicationInstances().Select(app => app.GetType().Name)
            };

            return(Ok(info));
        }
        public static IConfigurationBuilder AddCubesConfigurationProvider(this IConfigurationBuilder configuration,
                                                                          ICubesEnvironment cubes)
        {
            var cubesConfig = new Dictionary <string, string>
            {
                { $"{CubesConstants.Configuration_Section}:Version", cubes.GetEnvironmentInformation().FullVersion },
                { $"{CubesConstants.Configuration_Section}:RootFolder", cubes.GetRootFolder() },
                { $"{CubesConstants.Configuration_Section}:AppsFolder", cubes.GetAppsFolder() },
                { $"{CubesConstants.Configuration_Section}:LogsFolder", cubes.GetFolder(CubesFolderKind.Logs) },
                { $"{CubesConstants.Configuration_Section}:SettingsFolder", cubes.GetSettingsFolder() },
                { $"{CubesConstants.Configuration_Section}:StorageFolder", cubes.GetStorageFolder() },
                { $"{CubesConstants.Configuration_Section}:TempFolder", cubes.GetFolder(CubesFolderKind.Temp) },
                { $"{CubesConstants.Configuration_Section}:StaticContentFolder", cubes.GetFolder(CubesFolderKind.Content) },
                { $"{CubesConstants.Configuration_Section}:BinariesFolder", cubes.GetBinariesFolder() },
            };
            var swaggerFiles = cubes
                               .GetSwaggerFiles()
                               .Select((f, i) => new KeyValuePair <string, string>($"{CubesConstants.Configuration_Section}:SwaggerFiles:{i}", f))
                               .ToList();

            foreach (var item in swaggerFiles)
            {
                cubesConfig.Add(item.Key, item.Value);
            }

            var allAssembliesWithControllers = cubes
                                               .GetActivatedApplications()
                                               .SelectMany(app => app.AssembliesWithControllers.ToList())
                                               .Select((f, i) => new KeyValuePair <string, string>($"{CubesConstants.Configuration_Section}:AssembliesWithControllers:{i}", f))
                                               .ToList();

            foreach (var item in allAssembliesWithControllers)
            {
                cubesConfig.Add(item.Key, item.Value);
            }

            configuration.AddInMemoryCollection(cubesConfig);
            return(configuration);
        }