Linux admin mode

This commit is contained in:
2023-08-30 01:04:05 +02:00
parent 7df9c28172
commit 880180f16a
9 changed files with 106 additions and 20 deletions

View File

@@ -44,7 +44,6 @@ public class PortWriterService : IHostedService
return;
}
using var tempFileStream = File.CreateText(filename);
var address = GetAddress();
if (address is null)
{
@@ -59,7 +58,23 @@ public class PortWriterService : IHostedService
return;
}
_logger.LogInformation("Writing port to {PortFile}", filename);
using var tempFileStream = File.CreateText(filename);
tempFileStream.Write(port.ToString());
Task.Run(async () =>
{
await Task.Delay(5000);
try
{
_logger.LogInformation("Deleting port file {PortFile}", filename);
File.Delete(filename);
}
catch (Exception e)
{
_logger.LogError(e, "Error while deleting port file {PortFile}", filename);
}
});
}
catch (Exception ex)
{