Skip to content

Commit

Permalink
#50
Browse files Browse the repository at this point in the history
  • Loading branch information
odesyatnyk committed Mar 18, 2020
1 parent f4934ba commit 4212b1b
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 210 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public class ConfigsImplementation : IAmRouteImplementation
{
public ConfigsImplementation() : base(blockActionIfInMaintenanceMode: false) { }

public Task Invalidate(HttpContext context)
public async Task Invalidate(HttpContext context)
{
ServicesContainer.MailConfigurationManager(Const.MAIL_CONFIG_PATH).InvalidateCache();
ServicesContainer.WardeinConfigurationManager(Const.WARDEIN_CONFIG_PATH).InvalidateCache();
new PollingImplementation().Restart(context);
return context.Response.WriteAsync($"Cached configs invalidated");
await new PollingImplementation().Restart(context);
await context.Response.WriteAsync($"Cached configs invalidated");
}
}
}
19 changes: 10 additions & 9 deletions Elfo.Wardein.APIs/RouteImplementations/PollingImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,36 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using PeterKottas.DotNetCore.WindowsService.Base;
using Warden;

namespace Elfo.Wardein.APIs
{
public class PollingImplementation : IAmRouteImplementation
{
#region Private variables
private readonly IMicroService microService;
private readonly IWarden wardenInstance;
#endregion

#region Constructor
public PollingImplementation() : base(blockActionIfInMaintenanceMode: false)
{
this.microService = Startup.ServiceProvider.GetService<IMicroService>();
this.wardenInstance = Startup.ServiceProvider.GetService<IWarden>();
}
#endregion

#region Public Methods

public Task Stop(HttpContext context)
public async Task Stop(HttpContext context)
{
microService.Stop();
return context.Response.WriteAsync($"Periodic check stopped");
await wardenInstance.StopAsync();
await context.Response.WriteAsync($"Periodic check stopped");
}

public Task Restart(HttpContext context)
public async Task Restart(HttpContext context)
{
Stop(context);
microService.Start();
return context.Response.WriteAsync($"Periodic check restarted");
await Stop(context);
await wardenInstance.StartAsync();
await context.Response.WriteAsync($"Periodic check restarted");
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion Elfo.Wardein.Core/DependencyInjection/ServicesContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void Configure()
/// <summary>
/// Gets the istance as singleton
/// </summary>
public static new ServicesContainer Current
public static ServicesContainer Current
{
get
{
Expand Down
90 changes: 0 additions & 90 deletions Elfo.Wardein.Services/CacheCleanUpService.cs

This file was deleted.

17 changes: 4 additions & 13 deletions Elfo.Wardein.Services/Elfo.Wardein.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.1.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elfo.CleanUpManager" Version="0.0.12" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.0" />
<PackageReference Include="PeterKottas.DotNetCore.WindowsService" Version="2.0.11" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Warden" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elfo.Wardein.APIs\Elfo.Wardein.APIs.csproj" />
<ProjectReference Include="..\Elfo.Wardein.Core\Elfo.Wardein.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Hosting">
<HintPath>..\..\..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.hosting\2.0.3\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.dll</HintPath>
</Reference>
<ProjectReference Include="..\Elfo.Wardein.APIs\Elfo.Wardein.API.csproj" />
<ProjectReference Include="..\Elfo.Wardein.Watchers\Elfo.Wardein.Watchers.csproj" />
</ItemGroup>

</Project>
56 changes: 56 additions & 0 deletions Elfo.Wardein.Services/ServiceBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Elfo.Wardein.APIs;
using Microsoft.AspNetCore.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Warden;
using Warden.Core;
using Microsoft.Extensions.Configuration;
using Elfo.Wardein.Integrations;
using Elfo.Wardein.Watchers.FileSystem;
using Elfo.Wardein.Watchers.WindowsService;
using Elfo.Wardein.Watchers.IISPool;

namespace Elfo.Wardein.Services
{
public class ServiceBuilder
{
static IWarden warden;

public async Task ConfigureAndRunWarden()
{
var appConfiguration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();

var connectionString = appConfiguration["ConnectionStrings:Db"];

var configuration = WardenConfiguration
.Create()
.IntegrateWithOracle(connectionString)
.AddFileSystemWatcher(null)
.AddWindowsServiceWatcher(null)
.AddIISPoolWatcher(null)
.Build();

warden = WardenInstance.Create(configuration);
await warden.StartAsync();
}

public async Task ConfigureAndRunAPIHosting()
{
await new WebHostBuilder()
.UseUrls("http://*:5000")
.UseKestrel()
.ConfigureServices(serviceCollection =>
{
serviceCollection.AddSingleton<IWarden>(warden);
})
.UseStartup<Startup>()
.Build()
.RunAsync();
}
}
}
59 changes: 0 additions & 59 deletions Elfo.Wardein.Services/WardeinService.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Elfo.Wardein.Watchers/IISPool/IISPoolWatcher.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Elfo.Wardein.Core;
using Elfo.Wardein.Core.Abstractions;
using Elfo.Wardein.Abstractions.Services;
using Elfo.Wardein.Core;
using Elfo.Wardein.Core.Helpers;
using Elfo.Wardein.Core.NotificationService;
using Elfo.Wardein.Core.ServiceManager;
Expand Down
10 changes: 8 additions & 2 deletions Elfo.Wardein.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elfo.Wardein.Core", "Elfo.W
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elfo.Wardein", "Elfo.Wardein\Elfo.Wardein.csproj", "{7EED5720-57EC-49E7-B831-C3E5538E7B3E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elfo.Wardein.APIs", "Elfo.Wardein.APIs\Elfo.Wardein.APIs.csproj", "{56FD636F-0F4E-4644-8713-6AA1FDFF713B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elfo.Wardein.API", "Elfo.Wardein.APIs\Elfo.Wardein.API.csproj", "{56FD636F-0F4E-4644-8713-6AA1FDFF713B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elfo.Wardein.Watchers", "Elfo.Wardein.Watchers\Elfo.Wardein.Watchers.csproj", "{69EDA8D3-51B4-4986-A6AD-E57514071EEC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elfo.Wardein.Integrations", "Elfo.Wardein.Integrations\Elfo.Wardein.Integrations.csproj", "{A9EBA788-3D89-4E26-ADB3-E3B29F4B0F7B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elfo.Wardein.Integrations.Tests", "Elfo.Wardein.Integrations.Tests\Elfo.Wardein.Integrations.Tests.csproj", "{92AA3962-F5B8-46DC-85FA-0E06987F8F22}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elfo.Wardein.Abstractions", "Elfo.Wardein.Abstractions\Elfo.Wardein.Abstractions.csproj", "{47568C8B-1053-4245-BF6C-5F4EC1F69BE8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elfo.Wardein.Abstractions", "Elfo.Wardein.Abstractions\Elfo.Wardein.Abstractions.csproj", "{47568C8B-1053-4245-BF6C-5F4EC1F69BE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elfo.Wardein.Services", "Elfo.Wardein.Services\Elfo.Wardein.Services.csproj", "{B744AEF5-79D6-4413-A921-D57D005FCE29}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -51,6 +53,10 @@ Global
{47568C8B-1053-4245-BF6C-5F4EC1F69BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47568C8B-1053-4245-BF6C-5F4EC1F69BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47568C8B-1053-4245-BF6C-5F4EC1F69BE8}.Release|Any CPU.Build.0 = Release|Any CPU
{B744AEF5-79D6-4413-A921-D57D005FCE29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B744AEF5-79D6-4413-A921-D57D005FCE29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B744AEF5-79D6-4413-A921-D57D005FCE29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B744AEF5-79D6-4413-A921-D57D005FCE29}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 1 addition & 2 deletions Elfo.Wardein/Elfo.Wardein.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elfo.Wardein.APIs\Elfo.Wardein.APIs.csproj" />
<ProjectReference Include="..\Elfo.Wardein.Watchers\Elfo.Wardein.Watchers.csproj" />
<ProjectReference Include="..\Elfo.Wardein.Services\Elfo.Wardein.Services.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 4212b1b

Please sign in to comment.