Skip to content

Commit 4ac399e

Browse files
committed
fixed windows service
1 parent c9dde2b commit 4ac399e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

code/backend/Cleanuparr.Api/Cleanuparr.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2424
</PackageReference>
2525
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.6" />
26+
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.6" />
2627
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.6" />
2728
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="9.0.6" />
2829
<PackageReference Include="Quartz" Version="3.14.0" />

code/backend/Cleanuparr.Api/Program.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Runtime.InteropServices;
12
using System.Text.Json.Serialization;
23
using Cleanuparr.Api;
34
using Cleanuparr.Api.DependencyInjection;
@@ -56,6 +57,18 @@
5657
// Add logging with proper service provider
5758
builder.Logging.AddLogging();
5859

60+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
61+
{
62+
builder.Host.UseWindowsService(options =>
63+
{
64+
options.ServiceName = "Cleanuparr";
65+
});
66+
builder.Logging.AddEventLog(settings =>
67+
{
68+
settings.SourceName = "Cleanuparr";
69+
});
70+
}
71+
5972
var app = builder.Build();
6073

6174
// Configure BASE_PATH immediately after app build and before any other configuration

installers/windows/cleanuparr-installer.iss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ Source: "appsettings.json"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall
4747

4848
[Dirs]
4949
Name: "{app}\config"; Permissions: everyone-full
50-
Name: "{app}\logs"; Permissions: everyone-full
5150

5251
[Icons]
5352
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
@@ -85,7 +84,6 @@ procedure CreateConfigDirs;
8584
begin
8685
// Create necessary directories with proper permissions
8786
ForceDirectories(ExpandConstant('{app}\config'));
88-
ForceDirectories(ExpandConstant('{app}\logs'));
8987
end;
9088
9189
function ServiceExists(ServiceName: string): Boolean;

0 commit comments

Comments
 (0)