/// <summary> /// Trace that the service is starting. /// </summary> public static void ServiceStarting( Context context, TimeSpan?serviceRunningLogInterval, AbsolutePath logFilePath, string?serviceName = null, IClock?clock = null, DateTime?processStartupTime = null) { var operationContext = new OperationContext(context); ServiceRunningTrackerResult = ServiceOfflineDurationTracker.Create( operationContext, SystemClock.Instance, new PassThroughFileSystem(), serviceRunningLogInterval, logFilePath, serviceName); var offlineTime = ServiceRunningTrackerResult.Then(r => r.GetLastServiceHeartbeatTime(operationContext)); LifetimeTrackerHelper = Tracing.LifetimeTrackerHelper.Starting(clock.GetUtcNow(), processStartupTime ?? GetProcessStartupTimeUtc(), offlineTime.Then(v => Result.Success(v.lastServiceHeartbeatTime))); var runtime = OperatingSystemHelper.GetRuntimeFrameworkNameAndVersion(); Trace(context, $"Starting CaSaaS instance. Runtime={runtime}{offlineTime.ToStringSelect(r => $". LastHeartBeatTime={r.lastServiceHeartbeatTime}, ShutdownCorrectly={r.shutdownCorrectly}")}"); }
private async Task <Negotiator> Index() { var vm = new AboutAdminViewModel(); var systemSettings = await SettingsService.GetSettingsAsync(); var type = Type.GetType("Mono.Runtime"); if (type != null) // mono { vm.Os = "Mono"; var displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); if (displayName != null) { vm.SystemVersion = displayName.Invoke(null, null).ToString(); } } else { // Windows vm.Os = OperatingSystemHelper.GetOs(); vm.SystemVersion = Environment.Version.ToString(); } vm.ApplicationVersion = AssemblyHelper.GetFileVersion(); vm.Branch = EnumHelper <Branches> .GetDisplayValue(systemSettings.Branch); vm.LogLevel = LogManager.Configuration.LoggingRules.FirstOrDefault(x => x.NameMatches("database"))?.Levels?.FirstOrDefault()?.Name ?? "Unknown"; return(View["About", vm]); }
public void FrameworkVersionShouldBeAvailableOnWindowsBox() { string frameworkAsText = OperatingSystemHelper.GetInstalledDotNetFrameworkVersion(); var noNetFrameworkIsDetected = "No .NET Framework is detected"; if (OperatingSystemHelper.IsUnixOS) { Assert.Equal(noNetFrameworkIsDetected, frameworkAsText); } else { Assert.NotEqual(noNetFrameworkIsDetected, frameworkAsText); } }
private static void SendServerInfo(ServantAgentConfiguration configuration) { ReplyOverHttp(new CommandResponse(CommandResponse.ResponseType.ServerInfo) { Message = Json.SerializeToString( new ServerInfo() { ServantVersion = configuration.Version, ServerName = Environment.MachineName, OperatingSystem = OperatingSystemHelper.GetOsVersion(), TotalSites = SiteManager.TotalSites, TotalApplicationPools = SiteManager.TotalApplicationPools } ), Success = true }); }
private async Task <AboutAdminViewModel> GetModel() { var vm = new AboutAdminViewModel(); var oAuth = Session[SessionKeys.OAuthToken]?.ToString() ?? string.Empty; if (!string.IsNullOrEmpty(oAuth)) { vm.OAuthEnabled = true; } var systemSettings = await SettingsService.GetSettingsAsync(); var type = Type.GetType("Mono.Runtime"); if (type != null) // mono { vm.Os = "Mono"; var displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); if (displayName != null) { vm.SystemVersion = displayName.Invoke(null, null).ToString(); } } else { // Windows vm.Os = OperatingSystemHelper.GetOs(); vm.SystemVersion = Environment.Version.ToString(); } vm.RunningDir = Environment.CurrentDirectory; vm.DbLocation = SqlConfig.CurrentPath; vm.ApplicationVersion = AssemblyHelper.GetFileVersion(); vm.Branch = EnumHelper <Branches> .GetBranchValue <BranchAttribute>(systemSettings.Branch).DisplayName; vm.LogLevel = LogManager.Configuration.LoggingRules.FirstOrDefault(x => x.NameMatches("database"))?.Levels?.FirstOrDefault()?.Name ?? "Unknown"; return(vm); }
/// <summary> /// Returns a canonicalized environment variable as a string. /// </summary> public static string ToCanonicalizedEnvVar(this string envVarAsString) => OperatingSystemHelper.CanonicalizeEnvVar(envVarAsString);
/// <summary> /// Returns a canonicalized path as a string. /// </summary> public static string ToCanonicalizedPath(this string pathAsString) => OperatingSystemHelper.CanonicalizePath(pathAsString);