mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Move LogEnvironmentInfo to StartupHelpers
This commit is contained in:
parent
421b062ca4
commit
0df899943f
@ -11,7 +11,6 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -115,11 +114,6 @@ namespace Emby.Server.Implementations
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ApplicationHost : IServerApplicationHost, IAsyncDisposable, IDisposable
|
public abstract class ApplicationHost : IServerApplicationHost, IAsyncDisposable, IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The environment variable prefixes to log at server startup.
|
|
||||||
/// </summary>
|
|
||||||
private static readonly string[] _relevantEnvVarPrefixes = { "JELLYFIN_", "DOTNET_", "ASPNETCORE_" };
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The disposable parts.
|
/// The disposable parts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -670,36 +664,6 @@ namespace Emby.Server.Implementations
|
|||||||
FindParts();
|
FindParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
|
|
||||||
{
|
|
||||||
// Distinct these to prevent users from reporting problems that aren't actually problems
|
|
||||||
var commandLineArgs = Environment
|
|
||||||
.GetCommandLineArgs()
|
|
||||||
.Distinct();
|
|
||||||
|
|
||||||
// Get all relevant environment variables
|
|
||||||
var allEnvVars = Environment.GetEnvironmentVariables();
|
|
||||||
var relevantEnvVars = new Dictionary<object, object>();
|
|
||||||
foreach (var key in allEnvVars.Keys)
|
|
||||||
{
|
|
||||||
if (_relevantEnvVarPrefixes.Any(prefix => key.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
|
|
||||||
{
|
|
||||||
relevantEnvVars.Add(key, allEnvVars[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.LogInformation("Environment Variables: {EnvVars}", relevantEnvVars);
|
|
||||||
logger.LogInformation("Arguments: {Args}", commandLineArgs);
|
|
||||||
logger.LogInformation("Operating system: {OS}", RuntimeInformation.OSDescription);
|
|
||||||
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
|
|
||||||
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
|
|
||||||
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
|
|
||||||
logger.LogInformation("Processor count: {ProcessorCount}", Environment.ProcessorCount);
|
|
||||||
logger.LogInformation("Program data path: {ProgramDataPath}", appPaths.ProgramDataPath);
|
|
||||||
logger.LogInformation("Web resources path: {WebPath}", appPaths.WebPath);
|
|
||||||
logger.LogInformation("Application directory: {ApplicationPath}", appPaths.ProgramSystemPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private X509Certificate2 GetCertificate(string path, string password)
|
private X509Certificate2 GetCertificate(string path, string password)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(path))
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -22,6 +25,43 @@ namespace Jellyfin.Server.Helpers;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class StartupHelpers
|
public static class StartupHelpers
|
||||||
{
|
{
|
||||||
|
private static readonly string[] _relevantEnvVarPrefixes = { "JELLYFIN_", "DOTNET_", "ASPNETCORE_" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logs relevant environment variables and information about the host.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">The logger to use.</param>
|
||||||
|
/// <param name="appPaths">The application paths to use.</param>
|
||||||
|
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
|
||||||
|
{
|
||||||
|
// Distinct these to prevent users from reporting problems that aren't actually problems
|
||||||
|
var commandLineArgs = Environment
|
||||||
|
.GetCommandLineArgs()
|
||||||
|
.Distinct();
|
||||||
|
|
||||||
|
// Get all relevant environment variables
|
||||||
|
var allEnvVars = Environment.GetEnvironmentVariables();
|
||||||
|
var relevantEnvVars = new Dictionary<object, object>();
|
||||||
|
foreach (var key in allEnvVars.Keys)
|
||||||
|
{
|
||||||
|
if (_relevantEnvVarPrefixes.Any(prefix => key.ToString()!.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
relevantEnvVars.Add(key, allEnvVars[key]!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("Environment Variables: {EnvVars}", relevantEnvVars);
|
||||||
|
logger.LogInformation("Arguments: {Args}", commandLineArgs);
|
||||||
|
logger.LogInformation("Operating system: {OS}", RuntimeInformation.OSDescription);
|
||||||
|
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
|
||||||
|
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
|
||||||
|
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
|
||||||
|
logger.LogInformation("Processor count: {ProcessorCount}", Environment.ProcessorCount);
|
||||||
|
logger.LogInformation("Program data path: {ProgramDataPath}", appPaths.ProgramDataPath);
|
||||||
|
logger.LogInformation("Web resources path: {WebPath}", appPaths.WebPath);
|
||||||
|
logger.LogInformation("Application directory: {ApplicationPath}", appPaths.ProgramSystemPath);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create the data, config and log paths from the variety of inputs(command line args,
|
/// Create the data, config and log paths from the variety of inputs(command line args,
|
||||||
/// environment variables) or decide on what default to use. For Windows it's %AppPath%
|
/// environment variables) or decide on what default to use. For Windows it's %AppPath%
|
||||||
|
@ -148,7 +148,7 @@ namespace Jellyfin.Server
|
|||||||
"Jellyfin version: {Version}",
|
"Jellyfin version: {Version}",
|
||||||
Assembly.GetEntryAssembly()!.GetName().Version!.ToString(3));
|
Assembly.GetEntryAssembly()!.GetName().Version!.ToString(3));
|
||||||
|
|
||||||
ApplicationHost.LogEnvironmentInfo(_logger, appPaths);
|
StartupHelpers.LogEnvironmentInfo(_logger, appPaths);
|
||||||
|
|
||||||
// If hosting the web client, validate the client content path
|
// If hosting the web client, validate the client content path
|
||||||
if (startupConfig.HostWebClient())
|
if (startupConfig.HostWebClient())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user