Adjust logging and add debugger option
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 1m12s
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 1m12s
This commit is contained in:
@@ -14,11 +14,11 @@ internal class Program
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration().WriteTo.File("HardwareMonitorService.log").CreateLogger();
|
||||
|
||||
Log.Logger.Information("Start");
|
||||
Log.Information("Start");
|
||||
|
||||
if (args.Contains("--install", StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Log.Logger.Information("Starting install...");
|
||||
Log.Information("Starting install...");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -48,14 +48,14 @@ internal class Program
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Logger.Error(exception, "Install");
|
||||
Log.Error(exception, "");
|
||||
}
|
||||
|
||||
Log.Logger.Information("Install complete");
|
||||
Log.Information("Install complete");
|
||||
}
|
||||
else if (args.Contains("--uninstall", StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Log.Logger.Information("Starting uninstall...");
|
||||
Log.Information("Starting uninstall...");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -69,43 +69,51 @@ internal class Program
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Logger.Error(exception, "Uninstall");
|
||||
Log.Error(exception, "");
|
||||
}
|
||||
|
||||
Log.Logger.Information("Uninstall complete");
|
||||
Log.Information("Uninstall complete");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Logger.Information("Starting");
|
||||
Log.Information("Starting");
|
||||
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Log.Information("Creating PipeSecurity");
|
||||
|
||||
var pipeSecurity = new PipeSecurity();
|
||||
pipeSecurity.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));
|
||||
|
||||
Log.Information("Creating NamedPipe");
|
||||
|
||||
var pipeWithSecurity = NamedPipeServerStreamAcl.Create(HardwareMonitorService.PipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 0, pipeSecurity);
|
||||
|
||||
Log.Information("Creating PipeServer");
|
||||
|
||||
var pipeServer = new PipeServer<IHardwareMonitorService>(new HardwarePipeSerializer(), pipeWithSecurity, () => new HardwareMonitorService());
|
||||
//var pipeServer = new PipeServer<IHardwareMonitorService>(
|
||||
// new HardwarePipeSerializer(),
|
||||
// HardwareMonitorService.PipeName,
|
||||
// () => new HardwareMonitorService());
|
||||
|
||||
Log.Information("Waiting for connection");
|
||||
|
||||
await pipeServer.WaitForConnectionAsync().ConfigureAwait(false);
|
||||
|
||||
Log.Information("Waiting for remote pipe to close");
|
||||
|
||||
await pipeServer.WaitForRemotePipeCloseAsync().ConfigureAwait(false);
|
||||
|
||||
Log.Information("Disposing pipe server");
|
||||
|
||||
pipeServer.Dispose();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Logger.Error(exception, "");
|
||||
Log.Error(exception, "");
|
||||
}
|
||||
}
|
||||
|
||||
Log.Logger.Information("Closing");
|
||||
Log.Information("Closing");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user