mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Merge pull request #38 from AnonymusRaccoon/systemd
Host: Cleaning up logs and lifetime on systemd
This commit is contained in:
commit
bc727abe01
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Hosting.Systemd;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Win32;
|
||||
using Serilog;
|
||||
@ -200,6 +201,7 @@ namespace Kyoo.Core
|
||||
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
||||
.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
|
||||
.UseEnvironment(_environment)
|
||||
.UseSystemd()
|
||||
.ConfigureAppConfiguration(x => _SetupConfig(x, args))
|
||||
.UseSerilog((host, services, builder) => _ConfigureLogging(builder, host.Configuration, services))
|
||||
.ConfigureServices(x => x.AddRouting())
|
||||
@ -259,7 +261,19 @@ namespace Kyoo.Core
|
||||
|
||||
const string template =
|
||||
"[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} "
|
||||
+ "({@i:0000000000})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}";
|
||||
+ "({@i:D10})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}";
|
||||
|
||||
if (SystemdHelpers.IsSystemdService())
|
||||
{
|
||||
const string syslogTemplate = "[{SourceContext,-35}] {Message:lj}{NewLine}{Exception}";
|
||||
|
||||
builder
|
||||
.WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code))
|
||||
.WriteTo.LocalSyslog("Kyoo", outputTemplate: syslogTemplate)
|
||||
.Enrich.WithThreadId()
|
||||
.Enrich.FromLogContext();
|
||||
return;
|
||||
}
|
||||
|
||||
builder
|
||||
.WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code))
|
||||
|
@ -23,10 +23,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Expressions" Version="3.2.0" />
|
||||
<PackageReference Include="Serilog.Sinks.SyslogMessages" Version="2.0.6" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
|
||||
<PackageReference Include="Autofac" Version="6.2.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
|
@ -9,6 +9,8 @@ Environment=KYOO_DATADIR=/var/lib/kyoo
|
||||
ExecStart=/usr/lib/kyoo/Kyoo.Host.Console
|
||||
Restart=on-abort
|
||||
TimeoutSec=20
|
||||
StandardOutput=null
|
||||
StandardError=null
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
x
Reference in New Issue
Block a user