-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
71a4ab4
commit 9fcb75c
Showing
32 changed files
with
808 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
| ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Tasklist.Background.Extensions | ||
{ | ||
public static class ConfigurationExtensions | ||
{ | ||
public static int ReadIntConfigValue(this IConfiguration configuration, string key, int defaultValue) | ||
{ | ||
var value = configuration[key]; | ||
if (value == null) | ||
{ | ||
return defaultValue; | ||
} | ||
int number; | ||
if(int.TryParse(value, out number)) | ||
{ | ||
return number; | ||
} | ||
return defaultValue; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
using System.Collections.Generic; | ||
using System.Net.WebSockets; | ||
using System.Threading.Tasks; | ||
|
||
namespace Tasklist.Background | ||
{ | ||
public interface IProcessRepository | ||
{ | ||
IReadOnlyCollection<ProcessInformation> ProcessInformation { get; set; } | ||
IReadOnlyCollection<ProcessInformation> ProcessInformation { get; } | ||
Task SetProcessInfo(IReadOnlyCollection<ProcessInformation> info); | ||
bool IsCpuHigh { get; set; } | ||
bool IsMemoryLow { get; set; } | ||
void AddSocket(WebSocket socket, TaskCompletionSource<object> tcs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
namespace Tasklist.Background | ||
{ | ||
public struct SysInfo : IEquatable<SysInfo> | ||
{ | ||
public bool HighCpu { get; set; } | ||
public bool LowMemory { get; set; } | ||
|
||
public bool Equals(SysInfo other) | ||
{ | ||
return HighCpu == other.HighCpu && LowMemory == other.LowMemory; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
return obj is SysInfo other && Equals(other); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return HashCode.Combine(HighCpu, LowMemory); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
using Tasklist.Background.Extensions; | ||
|
||
namespace Tasklist.Background | ||
{ | ||
public class SysInfoHostedService : BackgroundService | ||
{ | ||
private readonly ILogger<SysInfoHostedService> _logger; | ||
private readonly IProcessRepository _processRepository; | ||
private readonly int _refreshRateInMs; | ||
private readonly int _cpuHighValue; | ||
private readonly int _memoryLowValue; | ||
public SysInfoHostedService(ILogger<SysInfoHostedService> logger, IProcessRepository processRepository, IConfiguration configuration) | ||
{ | ||
_logger = logger; | ||
_processRepository = processRepository; | ||
_refreshRateInMs = configuration.ReadIntConfigValue("TasklistRefreshRateMS", 50); | ||
_cpuHighValue = configuration.ReadIntConfigValue("cpuHighValue", 90); | ||
_memoryLowValue = configuration.ReadIntConfigValue("memoryLowValue", 1024); | ||
} | ||
|
||
public override async Task StopAsync(CancellationToken stoppingToken) | ||
{ | ||
_logger.LogInformation($"{GetType().Name} is stopping."); | ||
|
||
await base.StopAsync(stoppingToken); | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
await BackgroundProcessing(stoppingToken); | ||
} | ||
|
||
private async Task BackgroundProcessing(CancellationToken stoppingToken) | ||
{ | ||
while (!stoppingToken.IsCancellationRequested) | ||
{ | ||
try | ||
{ | ||
var info = ReadSysInfo(); | ||
_processRepository.IsMemoryLow = info.LowMemory; | ||
_processRepository.IsCpuHigh = info.HighCpu; | ||
|
||
await Task.Delay(TimeSpan.FromMilliseconds(_refreshRateInMs), stoppingToken); | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, $"Error occurred executing {GetType().Name}"); | ||
} | ||
} | ||
} | ||
|
||
private SysInfo ReadSysInfo() | ||
{ | ||
var query = "(Get-Counter -Counter '\\Memory\\Available MBytes','\\Processor(_Total)\\% Processor Time').CounterSamples.CookedValue"; | ||
// powershell may not work on machine where it would be ran. So consider yo use WMI too | ||
var stringData = string.Empty; | ||
var errorData = string.Empty; | ||
using (var process = new Process()) | ||
{ | ||
process.StartInfo.FileName = "powershell.exe"; | ||
process.StartInfo.Arguments = $"-NoProfile -ExecutionPolicy unrestricted \"{query }\""; | ||
process.StartInfo.CreateNoWindow = true; | ||
process.StartInfo.UseShellExecute = false; | ||
process.StartInfo.RedirectStandardOutput = true; | ||
process.StartInfo.RedirectStandardError = true; | ||
|
||
process.OutputDataReceived += (sender, data) => | ||
{ | ||
if (!string.IsNullOrEmpty(data.Data)) | ||
{ | ||
stringData += data.Data + Environment.NewLine; | ||
} | ||
}; | ||
process.ErrorDataReceived += (sender, data) => errorData += data.Data; | ||
process.Start(); | ||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
process.WaitForExit(1000 * 10); | ||
} | ||
if (!string.IsNullOrEmpty(errorData)) | ||
{ | ||
_logger.LogError(errorData); | ||
} | ||
try | ||
{ | ||
if (!string.IsNullOrEmpty(stringData)) | ||
{ | ||
var data = stringData.Split(Environment.NewLine); | ||
float memory; | ||
float.TryParse(data[0], out memory); | ||
|
||
float cpu; | ||
float.TryParse(data[1], out cpu); | ||
|
||
return new SysInfo | ||
{ | ||
HighCpu = cpu > _cpuHighValue, | ||
LowMemory = memory < _memoryLowValue | ||
}; | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
_logger.LogError(e, "oops"); | ||
} | ||
|
||
return new SysInfo(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
using System.Reflection; | ||
|
||
namespace Tasklist.Middleware.Websocket | ||
{ | ||
public static class WebSocketExtensions | ||
{ | ||
public static IServiceCollection AddWebSocketManager(this IServiceCollection services) | ||
{ | ||
services.AddTransient<WebSocketConnectionManager>(); | ||
|
||
foreach (var type in Assembly.GetEntryAssembly().ExportedTypes) | ||
{ | ||
if (type.GetTypeInfo().BaseType == typeof(WebSocketHandler)) | ||
{ | ||
services.AddSingleton(type); | ||
} | ||
} | ||
|
||
return services; | ||
} | ||
|
||
public static IApplicationBuilder MapWebSocket(this IApplicationBuilder app, | ||
PathString path, | ||
WebSocketHandler handler) | ||
{ | ||
return app.Map(path, (_app) => _app.UseMiddleware<WebSocketMiddleware>(handler)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Idea taken from https://radu-matei.com/blog/aspnet-core-websockets-middleware/ |
48 changes: 48 additions & 0 deletions
48
Tasklist.Middleware/Websocket/WebSocketConnectionManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Linq; | ||
using System.Net.WebSockets; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Tasklist.Middleware.Websocket | ||
{ | ||
public class WebSocketConnectionManager | ||
{ | ||
private readonly ConcurrentDictionary<string, WebSocket> _sockets = new ConcurrentDictionary<string, WebSocket>(); | ||
|
||
public WebSocket GetSocketById(string id) | ||
{ | ||
return _sockets.FirstOrDefault(p => p.Key == id).Value; | ||
} | ||
|
||
public ConcurrentDictionary<string, WebSocket> GetAll() | ||
{ | ||
return _sockets; | ||
} | ||
|
||
public string GetId(WebSocket socket) | ||
{ | ||
return _sockets.FirstOrDefault(p => p.Value == socket).Key; | ||
} | ||
public void AddSocket(WebSocket socket) | ||
{ | ||
_sockets.TryAdd(CreateConnectionId(), socket); | ||
} | ||
|
||
public async Task RemoveSocket(string id) | ||
{ | ||
if (_sockets.TryRemove(id, out var socket)) | ||
{ | ||
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, | ||
"Closed by connection manager", | ||
CancellationToken.None); | ||
} | ||
} | ||
|
||
private string CreateConnectionId() | ||
{ | ||
return Guid.NewGuid().ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Net.WebSockets; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Tasklist.Middleware.Websocket | ||
{ | ||
public abstract class WebSocketHandler | ||
{ | ||
protected WebSocketConnectionManager ConnectionManager { get; set; } | ||
|
||
protected WebSocketHandler(WebSocketConnectionManager connectionManager) | ||
{ | ||
ConnectionManager = connectionManager; | ||
} | ||
|
||
public virtual async Task OnConnected(WebSocket socket) | ||
{ | ||
ConnectionManager.AddSocket(socket); | ||
} | ||
|
||
public virtual async Task OnDisconnected(WebSocket socket) | ||
{ | ||
await ConnectionManager.RemoveSocket(ConnectionManager.GetId(socket)); | ||
} | ||
|
||
public async Task SendMessageAsync(WebSocket socket, string message) | ||
{ | ||
if (socket.State != WebSocketState.Open) | ||
return; | ||
|
||
await socket.SendAsync(new ArraySegment<byte>(Encoding.ASCII.GetBytes(message), 0, message.Length), | ||
WebSocketMessageType.Text, | ||
true, | ||
CancellationToken.None); | ||
|
||
} | ||
|
||
public async Task SendMessageAsync(string socketId, string message) | ||
{ | ||
await SendMessageAsync(ConnectionManager.GetSocketById(socketId), message); | ||
} | ||
|
||
public async Task SendMessageToAllAsync(string message) | ||
{ | ||
foreach (var (_, value) in ConnectionManager.GetAll()) | ||
{ | ||
if (value.State == WebSocketState.Open) | ||
await SendMessageAsync(value, message); | ||
} | ||
} | ||
|
||
//TODO - decide if exposing the message string is better than exposing the result and buffer | ||
public abstract Task ReceiveAsync(WebSocket socket, WebSocketReceiveResult result, byte[] buffer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
using System; | ||
using System.Net.WebSockets; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
|
||
namespace Tasklist.Middleware.Websocket | ||
{ | ||
public class WebSocketMiddleware | ||
{ | ||
private readonly RequestDelegate _next; | ||
private readonly WebSocketHandler _webSocketHandler; | ||
|
||
public WebSocketMiddleware(RequestDelegate next, WebSocketHandler webSocketHandler) | ||
{ | ||
_next = next; | ||
_webSocketHandler = webSocketHandler; | ||
} | ||
|
||
public async Task Invoke(HttpContext context) | ||
{ | ||
if (!context.WebSockets.IsWebSocketRequest) | ||
return; | ||
|
||
var socket = await context.WebSockets.AcceptWebSocketAsync(); | ||
await _webSocketHandler.OnConnected(socket); | ||
|
||
await Receive(socket, async (result, buffer) => | ||
{ | ||
if (result.MessageType == WebSocketMessageType.Text) | ||
{ | ||
await _webSocketHandler.ReceiveAsync(socket, result, buffer); | ||
return; | ||
} | ||
|
||
if (result.MessageType == WebSocketMessageType.Close) | ||
{ | ||
await _webSocketHandler.OnDisconnected(socket); | ||
} | ||
}); | ||
|
||
// short-circuit pipeline | ||
} | ||
|
||
private async Task Receive(WebSocket socket, Action<WebSocketReceiveResult, byte[]> handleMessage) | ||
{ | ||
var buffer = new byte[1024 * 4]; | ||
|
||
while (socket.State == WebSocketState.Open) | ||
{ | ||
var result = await socket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None); | ||
|
||
handleMessage(result, buffer); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"dotnet-ef": { | ||
"version": "3.1.4", | ||
"commands": [ | ||
"dotnet-ef" | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
{ | ||
"short_name": "WebApplication1", | ||
"name": "WebApplication1", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
} | ||
], | ||
"start_url": "./index.html", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
"short_name": "Tasklist", | ||
"name": "Tasklist", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
} | ||
], | ||
"start_url": "./index.html", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Net.WebSockets; | ||
using System.Text.Json; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using Tasklist.Background; | ||
using Tasklist.Middleware.Websocket; | ||
|
||
namespace Tasklist.Web | ||
{ | ||
public class LowSysInfoWebSocket : WebSocketHandler | ||
{ | ||
private readonly IProcessRepository _processRepository; | ||
private CancellationTokenSource _stoppingToken; | ||
|
||
public LowSysInfoWebSocket(WebSocketConnectionManager connectionManager, IProcessRepository processRepository) : base(connectionManager) | ||
{ | ||
_processRepository = processRepository; | ||
} | ||
|
||
public override async Task OnConnected(WebSocket socket) | ||
{ | ||
await base.OnConnected(socket); | ||
_stoppingToken = new CancellationTokenSource(); | ||
await Task.Run(async () => | ||
{ | ||
SysInfo lastSent = new SysInfo(); | ||
while (!_stoppingToken.IsCancellationRequested) | ||
{ | ||
var info = new SysInfo { HighCpu = _processRepository.IsCpuHigh, LowMemory = _processRepository.IsMemoryLow }; | ||
if (!info.Equals(lastSent)) | ||
{ | ||
lastSent = info; | ||
await SendMessageAsync(socket, JsonSerializer.Serialize(info, | ||
new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase })); | ||
} | ||
|
||
await Task.Delay(TimeSpan.FromMilliseconds(100)); | ||
} | ||
}, _stoppingToken.Token); | ||
} | ||
|
||
|
||
|
||
public override Task OnDisconnected(WebSocket socket) | ||
{ | ||
_stoppingToken.Cancel(); | ||
return base.OnDisconnected(socket); | ||
} | ||
|
||
public override Task ReceiveAsync(WebSocket socket, WebSocketReceiveResult result, byte[] buffer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@using WebApplication1 | ||
@namespace WebApplication1.Pages | ||
@using Tasklist | ||
@namespace Tasklist.Pages | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Net.WebSockets; | ||
using System.Text.Json; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using Microsoft.EntityFrameworkCore.Internal; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
using Tasklist.Background; | ||
using Tasklist.Middleware.Websocket; | ||
|
||
namespace Tasklist.Web | ||
{ | ||
|
||
public class ProcessListWebSocket : WebSocketHandler | ||
{ | ||
private readonly IProcessRepository _processRepository; | ||
private CancellationTokenSource _stoppingToken; | ||
private readonly int _refreshRateInMS; | ||
public ProcessListWebSocket(WebSocketConnectionManager connectionManager, IProcessRepository processRepository, IConfiguration configuration) : base(connectionManager) | ||
{ | ||
_processRepository = processRepository; | ||
int.TryParse(configuration["TasklistRefreshRateMS"], out _refreshRateInMS); | ||
if (_refreshRateInMS == 0) | ||
{ | ||
_refreshRateInMS = 50; | ||
} | ||
} | ||
|
||
public override async Task OnConnected(WebSocket socket) | ||
{ | ||
await base.OnConnected(socket); | ||
_stoppingToken = new CancellationTokenSource(); | ||
await Task.Run(async () => | ||
{ | ||
while (!_stoppingToken.IsCancellationRequested) | ||
{ | ||
if (_processRepository.ProcessInformation.Any()) | ||
{ | ||
await SendMessageAsync(socket, JsonSerializer.Serialize(_processRepository.ProcessInformation, | ||
new JsonSerializerOptions | ||
{ | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase | ||
})); | ||
} | ||
|
||
await Task.Delay(TimeSpan.FromMilliseconds(_refreshRateInMS)); | ||
} | ||
}, _stoppingToken.Token); | ||
} | ||
|
||
public override Task OnDisconnected(WebSocket socket) | ||
{ | ||
_stoppingToken.Cancel(); | ||
return base.OnDisconnected(socket); | ||
} | ||
|
||
public override Task ReceiveAsync(WebSocket socket, WebSocketReceiveResult result, byte[] buffer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Tasklist.Web/Properties/PublishProfiles/FolderProfile.pubxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
https://go.microsoft.com/fwlink/?LinkID=208121. | ||
--> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<DeleteExistingFiles>True</DeleteExistingFiles> | ||
<ExcludeApp_Data>False</ExcludeApp_Data> | ||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish> | ||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration> | ||
<LastUsedPlatform>Any CPU</LastUsedPlatform> | ||
<PublishProvider>FileSystem</PublishProvider> | ||
<PublishUrl>bin\Debug\netcoreapp3.1\publish\</PublishUrl> | ||
<WebPublishMethod>FileSystem</WebPublishMethod> | ||
<SiteUrlToLaunchAfterPublish /> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<ProjectGuid>3338af6d-a01e-4afa-8120-7cc693b71d78</ProjectGuid> | ||
<SelfContained>false</SelfContained> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iis": { | ||
"applicationUrl": "http://localhost/tasklist", | ||
"sslPort": 0 | ||
}, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:53854", | ||
"sslPort": 44336 | ||
} | ||
}, | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"Tasklist.Web": { | ||
"commandName": "Project", | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000" | ||
}, | ||
"IIS": { | ||
"commandName": "IIS", | ||
"launchBrowser": true, | ||
"launchUrl": "", | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
"ASPNETCORE_ENVIRONMENT": "Staging" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
"TasklistRefreshRateMS": 50 | ||
"TasklistRefreshRateMS": 50, | ||
"cpuHighValue": "40", | ||
"memoryLowValue": "4024" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<location path="." inheritInChildApplications="false"> | ||
<system.webServer> | ||
<handlers> | ||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> | ||
</handlers> | ||
<aspNetCore processPath="%LAUNCHER_PATH%" stdoutLogEnabled="false" hostingModel="InProcess"> | ||
<environmentVariables> | ||
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44336" /> | ||
<environmentVariable name="COMPLUS_ForceENC" value="1" /> | ||
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> | ||
</environmentVariables> | ||
</aspNetCore> | ||
</system.webServer> | ||
</location> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters