|
|
|
@ -35,6 +35,7 @@ namespace Jellyfin.Server
|
|
|
|
|
private static readonly ILoggerFactory _loggerFactory = new SerilogLoggerFactory();
|
|
|
|
|
private static ILogger _logger;
|
|
|
|
|
private static bool _restartOnShutdown;
|
|
|
|
|
private static IConfiguration appConfig;
|
|
|
|
|
|
|
|
|
|
public static async Task Main(string[] args)
|
|
|
|
|
{
|
|
|
|
@ -78,7 +79,11 @@ namespace Jellyfin.Server
|
|
|
|
|
|
|
|
|
|
// $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
|
|
|
|
|
Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", appPaths.LogDirectoryPath);
|
|
|
|
|
await CreateLogger(appPaths).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
appConfig = await CreateConfiguration(appPaths).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
CreateLogger(appConfig, appPaths);
|
|
|
|
|
|
|
|
|
|
_logger = _loggerFactory.CreateLogger("Main");
|
|
|
|
|
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += (sender, e)
|
|
|
|
@ -121,7 +126,7 @@ namespace Jellyfin.Server
|
|
|
|
|
// Allow all https requests
|
|
|
|
|
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; } );
|
|
|
|
|
|
|
|
|
|
var fileSystem = new ManagedFileSystem(_loggerFactory, environmentInfo, null, appPaths.TempDirectory, true);
|
|
|
|
|
var fileSystem = new ManagedFileSystem(_loggerFactory, environmentInfo, appPaths);
|
|
|
|
|
|
|
|
|
|
using (var appHost = new CoreAppHost(
|
|
|
|
|
appPaths,
|
|
|
|
@ -130,7 +135,8 @@ namespace Jellyfin.Server
|
|
|
|
|
fileSystem,
|
|
|
|
|
environmentInfo,
|
|
|
|
|
new NullImageEncoder(),
|
|
|
|
|
new NetworkManager(_loggerFactory, environmentInfo)))
|
|
|
|
|
new NetworkManager(_loggerFactory, environmentInfo),
|
|
|
|
|
appConfig))
|
|
|
|
|
{
|
|
|
|
|
await appHost.Init(new ServiceCollection()).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
@ -309,9 +315,7 @@ namespace Jellyfin.Server
|
|
|
|
|
return new ServerApplicationPaths(dataDir, logDir, configDir, cacheDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async Task CreateLogger(IApplicationPaths appPaths)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
private static async Task<IConfiguration> CreateConfiguration(IApplicationPaths appPaths)
|
|
|
|
|
{
|
|
|
|
|
string configPath = Path.Combine(appPaths.ConfigurationDirectoryPath, "logging.json");
|
|
|
|
|
|
|
|
|
@ -326,12 +330,18 @@ namespace Jellyfin.Server
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
|
|
|
return new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(appPaths.ConfigurationDirectoryPath)
|
|
|
|
|
.AddJsonFile("logging.json")
|
|
|
|
|
.AddEnvironmentVariables("JELLYFIN_")
|
|
|
|
|
.AddInMemoryCollection(ConfigurationOptions.Configuration)
|
|
|
|
|
.Build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CreateLogger(IConfiguration configuration, IApplicationPaths appPaths)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Serilog.Log is used by SerilogLoggerFactory when no logger is specified
|
|
|
|
|
Serilog.Log.Logger = new LoggerConfiguration()
|
|
|
|
|
.ReadFrom.Configuration(configuration)
|
|
|
|
|