diff --git a/.env.example b/.env.example index e46503ed..d20e7e37 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ # Useful config options -LIBRARY_ROOT=./video +LIBRARY_ROOT=/video TVDB__APIKEY= THEMOVIEDB__APIKEY= PUBLIC_BACK_URL=http://localhost:5000 diff --git a/back/src/Kyoo.Abstractions/Controllers/IPlugin.cs b/back/src/Kyoo.Abstractions/Controllers/IPlugin.cs index 55c5b6e4..c7b09229 100644 --- a/back/src/Kyoo.Abstractions/Controllers/IPlugin.cs +++ b/back/src/Kyoo.Abstractions/Controllers/IPlugin.cs @@ -66,14 +66,7 @@ namespace Kyoo.Abstractions.Controllers /// /// If a field should be loosely typed, or null /// can be specified. - /// WARNING: null means an unmanaged type that won't be editable. This can be used - /// for external libraries or variable arguments. /// - /// - /// All use of the configuration must be specified here and not registered elsewhere, if a type is registered - /// elsewhere the configuration won't be editable via the and all values - /// will be discarded on edit. - /// Dictionary Configuration { get; } /// diff --git a/back/src/Kyoo.Core/Models/Options/BasicOptions.cs b/back/src/Kyoo.Core/Models/Options/BasicOptions.cs index 6e61e311..1536004d 100644 --- a/back/src/Kyoo.Core/Models/Options/BasicOptions.cs +++ b/back/src/Kyoo.Core/Models/Options/BasicOptions.cs @@ -28,11 +28,6 @@ namespace Kyoo.Core.Models.Options /// public const string Path = "Basics"; - /// - /// The internal url where the server will listen. It supports globing. - /// - public string Url { get; set; } = "http://*:5000"; - /// /// The path of the plugin directory. /// diff --git a/back/src/Kyoo.Host/Application.cs b/back/src/Kyoo.Host/Application.cs index df492c0c..0e677ba5 100644 --- a/back/src/Kyoo.Host/Application.cs +++ b/back/src/Kyoo.Host/Application.cs @@ -29,6 +29,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Serilog; +using Serilog.Events; using Serilog.Templates; using Serilog.Templates.Themes; using ILogger = Serilog.ILogger; @@ -85,6 +86,16 @@ namespace Kyoo.Host /// A task representing the whole process public async Task Start(string[] args, Action configure) { + IConfiguration parsed = new ConfigurationBuilder() + .AddEnvironmentVariables() + .AddEnvironmentVariables("KYOO_") + .AddCommandLine(args) + .Build(); + string path = Path.GetFullPath(parsed.GetValue("DATADIR", "/kyoo")); + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + Environment.CurrentDirectory = path; + LoggerConfiguration config = new(); _ConfigureLogging(config); Log.Logger = config.CreateBootstrapLogger(); @@ -112,6 +123,7 @@ namespace Kyoo.Host try { _logger.Information("Version: {Version}", Assembly.GetExecutingAssembly().GetName().Version.ToString(3)); + _logger.Information("Data directory: {DataDirectory}", Environment.CurrentDirectory); await host.RunAsync(cancellationToken); } catch (Exception ex) @@ -168,6 +180,9 @@ namespace Kyoo.Host "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 25} " + "({@i:D10})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; builder + .MinimumLevel.Warning() + .MinimumLevel.Override("Kyoo", LogEventLevel.Verbose) + .MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Verbose) .WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code)) .Enrich.WithThreadId() .Enrich.FromLogContext(); diff --git a/back/src/Kyoo.Host/Kyoo.Host.csproj b/back/src/Kyoo.Host/Kyoo.Host.csproj index 6d391737..434538ac 100644 --- a/back/src/Kyoo.Host/Kyoo.Host.csproj +++ b/back/src/Kyoo.Host/Kyoo.Host.csproj @@ -1,7 +1,9 @@ - - + - Kyoo.Host + Exe + Kyoo.Host + Kyoo.Host + Kyoo.Host.Program @@ -25,8 +27,4 @@ - - - - diff --git a/back/src/Kyoo.Host/settings.json b/back/src/Kyoo.Host/settings.json index 04378c12..e9e70933 100644 --- a/back/src/Kyoo.Host/settings.json +++ b/back/src/Kyoo.Host/settings.json @@ -6,18 +6,6 @@ "metadataPath": "metadata/" }, - "logging": { - "MinimumLevel": { - "Default": "Warning", - "Override": { - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information", - "Microsoft.EntityFrameworkCore": "Fatal", - "Kyoo": "Verbose" - } - } - }, - "tasks": { "parallels": "1", "scheduled": {