aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Server')
-rw-r--r--Jellyfin.Server/CoreAppHost.cs4
-rw-r--r--Jellyfin.Server/Jellyfin.Server.csproj1
-rw-r--r--Jellyfin.Server/PowerManagement.cs23
-rw-r--r--Jellyfin.Server/Program.cs73
-rw-r--r--Jellyfin.Server/Resources/Configuration/logging.json19
5 files changed, 65 insertions, 55 deletions
diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.cs
index b54634387..64e03f22e 100644
--- a/Jellyfin.Server/CoreAppHost.cs
+++ b/Jellyfin.Server/CoreAppHost.cs
@@ -11,8 +11,8 @@ namespace Jellyfin.Server
{
public class CoreAppHost : ApplicationHost
{
- public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager)
- : base(applicationPaths, loggerFactory, options, fileSystem, powerManagement, environmentInfo, imageEncoder, systemEvents, networkManager)
+ public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager)
+ : base(applicationPaths, loggerFactory, options, fileSystem, environmentInfo, imageEncoder, systemEvents, networkManager)
{
}
diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj
index 8ecae1b5b..98c578e83 100644
--- a/Jellyfin.Server/Jellyfin.Server.csproj
+++ b/Jellyfin.Server/Jellyfin.Server.csproj
@@ -25,6 +25,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
+ <PackageReference Include="Serilog.Sinks.Async" Version="1.3.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
<PackageReference Include="SkiaSharp" Version="1.68.0" />
diff --git a/Jellyfin.Server/PowerManagement.cs b/Jellyfin.Server/PowerManagement.cs
deleted file mode 100644
index c27c51893..000000000
--- a/Jellyfin.Server/PowerManagement.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using MediaBrowser.Model.System;
-
-namespace Jellyfin.Server.Native
-{
- public class PowerManagement : IPowerManagement
- {
- public void PreventSystemStandby()
- {
-
- }
-
- public void AllowSystemStandby()
- {
-
- }
-
- public void ScheduleWake(DateTime wakeTimeUtc, string displayName)
- {
-
- }
- }
-}
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 2dd4d9af6..d74315755 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -13,7 +13,6 @@ using Emby.Server.Implementations;
using Emby.Server.Implementations.EnvironmentInfo;
using Emby.Server.Implementations.IO;
using Emby.Server.Implementations.Networking;
-using Jellyfin.Server.Native;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Drawing;
@@ -47,6 +46,8 @@ namespace Jellyfin.Server
}
ServerApplicationPaths appPaths = createApplicationPaths(options);
+ // $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
+ Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", appPaths.LogDirectoryPath);
await createLogger(appPaths);
_loggerFactory = new SerilogLoggerFactory();
_logger = _loggerFactory.CreateLogger("Main");
@@ -71,7 +72,6 @@ namespace Jellyfin.Server
_loggerFactory,
options,
fileSystem,
- new PowerManagement(),
environmentInfo,
new NullImageEncoder(),
new SystemEvents(_loggerFactory.CreateLogger("SystemEvents")),
@@ -102,43 +102,66 @@ namespace Jellyfin.Server
private static ServerApplicationPaths createApplicationPaths(StartupOptions options)
{
- string programDataPath;
- if (options.ContainsOption("-programdata"))
+ string programDataPath = Environment.GetEnvironmentVariable("JELLYFIN_DATA_PATH");
+ if (string.IsNullOrEmpty(programDataPath))
{
- programDataPath = options.GetOption("-programdata");
- }
- else
- {
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (options.ContainsOption("-programdata"))
{
- programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ programDataPath = options.GetOption("-programdata");
}
else
{
- // $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
- programDataPath = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
- // If $XDG_DATA_HOME is either not set or empty, $HOME/.local/share should be used.
- if (string.IsNullOrEmpty(programDataPath))
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ }
+ else
{
- programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
+ // $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
+ programDataPath = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
+ // If $XDG_DATA_HOME is either not set or empty, $HOME/.local/share should be used.
+ if (string.IsNullOrEmpty(programDataPath))
+ {
+ programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
+ }
}
+ programDataPath = Path.Combine(programDataPath, "jellyfin");
+ // Ensure the dir exists
+ Directory.CreateDirectory(programDataPath);
+ }
+ }
+
+ string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
+ if (string.IsNullOrEmpty(configDir))
+ {
+ if (options.ContainsOption("-configdir"))
+ {
+ configDir = options.GetOption("-configdir");
+ }
+ else
+ {
+ // Let BaseApplicationPaths set up the default value
+ configDir = null;
}
- programDataPath = Path.Combine(programDataPath, "jellyfin");
}
string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
if (string.IsNullOrEmpty(logDir))
{
- logDir = Path.Combine(programDataPath, "logs");
- // Ensure logDir exists
- Directory.CreateDirectory(logDir);
- // $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
- Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", logDir);
+ if (options.ContainsOption("-logdir"))
+ {
+ logDir = options.GetOption("-logdir");
+ }
+ else
+ {
+ // Let BaseApplicationPaths set up the default value
+ logDir = null;
+ }
}
string appPath = AppContext.BaseDirectory;
- return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir);
+ return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configDir);
}
private static async Task createLogger(IApplicationPaths appPaths)
@@ -173,10 +196,10 @@ namespace Jellyfin.Server
{
Serilog.Log.Logger = new LoggerConfiguration()
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss}] [{Level:u3}] {Message:lj}{NewLine}{Exception}")
- .WriteTo.File(
+ .WriteTo.Async(x => x.File(
Path.Combine(appPaths.LogDirectoryPath, "log_.log"),
rollingInterval: RollingInterval.Day,
- outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}")
+ outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}"))
.Enrich.FromLogContext()
.CreateLogger();
@@ -233,7 +256,7 @@ namespace Jellyfin.Server
}
}
- public static void Shutdown()
+ public static void Shutdown()
{
ApplicationTaskCompletionSource.SetResult(true);
}
diff --git a/Jellyfin.Server/Resources/Configuration/logging.json b/Jellyfin.Server/Resources/Configuration/logging.json
index 78f99b2ad..d16991277 100644
--- a/Jellyfin.Server/Resources/Configuration/logging.json
+++ b/Jellyfin.Server/Resources/Configuration/logging.json
@@ -2,16 +2,25 @@
"Serilog": {
"MinimumLevel": "Information",
"WriteTo": [
- { "Name": "Console",
+ {
+ "Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss}] [{Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
- { "Name": "File",
+ {
+ "Name": "Async",
"Args": {
- "path": "%JELLYFIN_LOG_DIR%//log_.log",
- "rollingInterval": "Day",
- "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}"
+ "configure": [
+ {
+ "Name": "File",
+ "Args": {
+ "path": "%JELLYFIN_LOG_DIR%//log_.log",
+ "rollingInterval": "Day",
+ "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}"
+ }
+ }
+ ]
}
}
]