From f073a11ce95b8d03c571f82762998c3a551d13b4 Mon Sep 17 00:00:00 2001 From: Atralupus Date: Wed, 21 Feb 2024 22:03:21 +0900 Subject: [PATCH] Init --- .../NineChroniclesUtilBackend.Store.csproj | 15 ++++++++++++ NineChroniclesUtilBackend.Store/Program.cs | 7 ++++++ .../Properties/launchSettings.json | 12 ++++++++++ NineChroniclesUtilBackend.Store/Worker.cs | 23 +++++++++++++++++++ .../appsettings.Development.json | 8 +++++++ .../appsettings.json | 8 +++++++ NineChroniclesUtilBackend.sln | 8 ++++++- 7 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 NineChroniclesUtilBackend.Store/NineChroniclesUtilBackend.Store.csproj create mode 100644 NineChroniclesUtilBackend.Store/Program.cs create mode 100644 NineChroniclesUtilBackend.Store/Properties/launchSettings.json create mode 100644 NineChroniclesUtilBackend.Store/Worker.cs create mode 100644 NineChroniclesUtilBackend.Store/appsettings.Development.json create mode 100644 NineChroniclesUtilBackend.Store/appsettings.json diff --git a/NineChroniclesUtilBackend.Store/NineChroniclesUtilBackend.Store.csproj b/NineChroniclesUtilBackend.Store/NineChroniclesUtilBackend.Store.csproj new file mode 100644 index 00000000..7947ef65 --- /dev/null +++ b/NineChroniclesUtilBackend.Store/NineChroniclesUtilBackend.Store.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + dotnet-NineChroniclesUtilBackend.Store-bccda56f-4d38-484b-ab03-ebb26065c837 + + + + + + + + diff --git a/NineChroniclesUtilBackend.Store/Program.cs b/NineChroniclesUtilBackend.Store/Program.cs new file mode 100644 index 00000000..1dc7b948 --- /dev/null +++ b/NineChroniclesUtilBackend.Store/Program.cs @@ -0,0 +1,7 @@ +using NineChroniclesUtilBackend.Store; + +var builder = Host.CreateApplicationBuilder(args); +builder.Services.AddHostedService(); + +var host = builder.Build(); +host.Run(); diff --git a/NineChroniclesUtilBackend.Store/Properties/launchSettings.json b/NineChroniclesUtilBackend.Store/Properties/launchSettings.json new file mode 100644 index 00000000..8efeb70e --- /dev/null +++ b/NineChroniclesUtilBackend.Store/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "NineChroniclesUtilBackend.Store": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} diff --git a/NineChroniclesUtilBackend.Store/Worker.cs b/NineChroniclesUtilBackend.Store/Worker.cs new file mode 100644 index 00000000..1ff95278 --- /dev/null +++ b/NineChroniclesUtilBackend.Store/Worker.cs @@ -0,0 +1,23 @@ +namespace NineChroniclesUtilBackend.Store; + +public class Worker : BackgroundService +{ + private readonly ILogger _logger; + + public Worker(ILogger logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + if (_logger.IsEnabled(LogLevel.Information)) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + } + await Task.Delay(1000, stoppingToken); + } + } +} diff --git a/NineChroniclesUtilBackend.Store/appsettings.Development.json b/NineChroniclesUtilBackend.Store/appsettings.Development.json new file mode 100644 index 00000000..69017646 --- /dev/null +++ b/NineChroniclesUtilBackend.Store/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/NineChroniclesUtilBackend.Store/appsettings.json b/NineChroniclesUtilBackend.Store/appsettings.json new file mode 100644 index 00000000..69017646 --- /dev/null +++ b/NineChroniclesUtilBackend.Store/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/NineChroniclesUtilBackend.sln b/NineChroniclesUtilBackend.sln index 08c079b7..2d78a670 100644 --- a/NineChroniclesUtilBackend.sln +++ b/NineChroniclesUtilBackend.sln @@ -1,10 +1,12 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NineChroniclesUtilBackend", "NineChroniclesUtilBackend\NineChroniclesUtilBackend.csproj", "{1909E492-D010-4FB5-BC4B-DEF73025C41E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NineChroniclesUtilBackend.Store", "NineChroniclesUtilBackend.Store\NineChroniclesUtilBackend.Store.csproj", "{462CDFD3-650B-46A7-A937-8E3BCE7E527C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,5 +20,9 @@ Global {1909E492-D010-4FB5-BC4B-DEF73025C41E}.Debug|Any CPU.Build.0 = Debug|Any CPU {1909E492-D010-4FB5-BC4B-DEF73025C41E}.Release|Any CPU.ActiveCfg = Release|Any CPU {1909E492-D010-4FB5-BC4B-DEF73025C41E}.Release|Any CPU.Build.0 = Release|Any CPU + {462CDFD3-650B-46A7-A937-8E3BCE7E527C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {462CDFD3-650B-46A7-A937-8E3BCE7E527C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {462CDFD3-650B-46A7-A937-8E3BCE7E527C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {462CDFD3-650B-46A7-A937-8E3BCE7E527C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal