Cleanup config options

This commit is contained in:
Zoe Roux 2023-03-16 14:47:18 +09:00
parent 03bd5b4c78
commit e17b4c6e23
6 changed files with 21 additions and 32 deletions

View File

@ -1,5 +1,5 @@
# Useful config options
LIBRARY_ROOT=./video
LIBRARY_ROOT=/video
TVDB__APIKEY=
THEMOVIEDB__APIKEY=
PUBLIC_BACK_URL=http://localhost:5000

View File

@ -66,14 +66,7 @@ namespace Kyoo.Abstractions.Controllers
///
/// If a field should be loosely typed, <see cref="Dictionary{TKey,TValue}"/> or <c>null</c>
/// can be specified.
/// WARNING: null means an unmanaged type that won't be editable. This can be used
/// for external libraries or variable arguments.
/// </summary>
/// <remarks>
/// 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 <see cref="IConfigurationManager"/> and all values
/// will be discarded on edit.
/// </remarks>
Dictionary<string, Type> Configuration { get; }
/// <summary>

View File

@ -28,11 +28,6 @@ namespace Kyoo.Core.Models.Options
/// </summary>
public const string Path = "Basics";
/// <summary>
/// The internal url where the server will listen. It supports globing.
/// </summary>
public string Url { get; set; } = "http://*:5000";
/// <summary>
/// The path of the plugin directory.
/// </summary>

View File

@ -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
/// <returns>A task representing the whole process</returns>
public async Task Start(string[] args, Action<ContainerBuilder> 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();

View File

@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<PackageId>Kyoo.Host</PackageId>
<OutputType>Exe</OutputType>
<AssemblyName>Kyoo.Host</AssemblyName>
<RootNamespace>Kyoo.Host</RootNamespace>
<StartupObject>Kyoo.Host.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
@ -25,8 +27,4 @@
<ProjectReference Include="../Kyoo.Authentication/Kyoo.Authentication.csproj" />
<ProjectReference Include="../Kyoo.Swagger/Kyoo.Swagger.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="settings.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>

View File

@ -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": {