Skip to content

Commit

Permalink
Trigger shutdown after multiple serial restart
Browse files Browse the repository at this point in the history
  • Loading branch information
gpproton committed Jan 26, 2022
1 parent 0352186 commit 16b7f5a
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions src/Frequency.Device/Handlers/ReaderProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
using Microsoft.Extensions.Logging;
using Proton.Frequency.Device.Handlers.ReaderConnections;
using Proton.Frequency.Device.Helpers;
using Proton.Frequency.Device.Protocols.Readers;
using Proton.Frequency.Device.Protocols;

namespace Proton.Frequency.Device.Handlers
Expand Down Expand Up @@ -219,20 +218,56 @@ void OnDevTest(Object source, System.Timers.ElapsedEventArgs e)
else if (!DevMode && !_serialProfile.IsOpen)
{
int maxRetries = _config.IOT_SERIAL_CONN_RETRY;
while (maxRetries > 0)
while (maxRetries > 1)
{
maxRetries--;
serialOpen();
await Task.Delay(2000);
}
}
}

public void NetworkConnection()
{ }
/**
String processDirectory = System.AppContext.BaseDirectory;
String processPath = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
String path = Path.Combine(processDirectory, processPath);
if (Path.IsPathFullyQualified(path))
{
String escapedArgs = path.Replace("\"", "\\\"");
String _filename = null;
String _arguments = null;
if (System.OperatingSystem.IsWindows())
{
_filename = "cmd.exe";
_arguments = $"/c \"{escapedArgs}\"";
}
else
{
_filename = "/bin/bash";
_arguments = $"-c \"{escapedArgs}\"";
}
public async Task Run()
{
await Task.CompletedTask;
var process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = _filename,
Arguments = _arguments,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};
_logger.LogWarning("Restarting application...");
process.Start();
process.WaitForExit();
}
*/

_logger.LogWarning("Shutting daemon process...");
/** System.Diagnostics.Process.Start(path); **/
Environment.Exit(0);

}
}

}
Expand Down

0 comments on commit 16b7f5a

Please sign in to comment.