RAIDAlert/Watchdog.cs

31 lines
902 B
C#

using CliWrap;
namespace RAIDAlert;
public class Watchdog : BackgroundService
{
private const string HpCliUtil = "hpssacli.exe";
private const string PcBeeperUtil = "pc-beeper.exe";
private readonly ILogger<Watchdog> _logger;
public Watchdog(ILogger<Watchdog> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
string hpSsaCli = Path.Combine(Environment.ProcessPath!, HpCliUtil);
string pcBeeper = Path.Combine(Environment.ProcessPath!, PcBeeperUtil);
while (!stoppingToken.IsCancellationRequested)
{
var result = await Cli.Wrap("path/to/exe")
.WithArguments(new[] {"--foo", "bar"})
.WithWorkingDirectory("work/dir/path")
.ExecuteAsync();
await Task.Delay(1000, stoppingToken);
}
}
}