feat(service): enable Windows Service hosting lifetime
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.1" />
|
||||||
<PackageReference Include="ModelContextProtocol" Version="1.2.0" />
|
<PackageReference Include="ModelContextProtocol" Version="1.2.0" />
|
||||||
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="1.2.0" />
|
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="1.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using ClaudeMailbox.Data.Repositories;
|
|||||||
using ClaudeMailbox.Http;
|
using ClaudeMailbox.Http;
|
||||||
using ClaudeMailbox.Mcp;
|
using ClaudeMailbox.Mcp;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Hosting.WindowsServices;
|
||||||
|
|
||||||
namespace ClaudeMailbox;
|
namespace ClaudeMailbox;
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ public static class ServerHost
|
|||||||
public static WebApplicationBuilder CreateBuilder(DaemonConfig cfg, string[]? args = null)
|
public static WebApplicationBuilder CreateBuilder(DaemonConfig cfg, string[]? args = null)
|
||||||
{
|
{
|
||||||
var builder = WebApplication.CreateBuilder(args ?? Array.Empty<string>());
|
var builder = WebApplication.CreateBuilder(args ?? Array.Empty<string>());
|
||||||
|
builder.Host.UseWindowsService(opt => opt.ServiceName = "ClaudeMailbox");
|
||||||
|
|
||||||
builder.Services.AddSingleton(cfg);
|
builder.Services.AddSingleton(cfg);
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|||||||
Reference in New Issue
Block a user