Hello folks here comes another one Watcher which is responsible for the process monitoring.
This one isn’t really sophisticated, as there isn’t not much to do in terms of the process validation, yet you might find it useful under certain situations.
The Process Watcher comes available as a NuGet package:
1 |
Install-Package Warden.Watchers.Process |
Having this guy installed, we can move further with the actual implementation:
1 2 3 4 5 6 7 8 9 10 |
var configuration = ProcessWatcherConfiguration .Create("mongod") .EnsureThat(process => process.Id == 1000) .Build(); var processWatcher = ProcessWatcher.Create("Process watcher", configuration); var wardenConfiguration = WardenConfiguration .Create() .AddWatcher(processWatcher ) //Configure other watchers, hooks etc. |
In that scenario, we want to verify that the process named mongod is running and on top of that, it has a PID of 1000 (as long as it makes any sense, which probably it doesn’t).
Surely, we can achieve the same result by using the extension methods:
1 2 3 4 5 6 7 |
var wardenConfiguration = WardenConfiguration .Create() .AddProcessWatcher("mongod", cfg => { cfg.EnsureThat(process => process.Id == 1000) }) //Configure other watchers, hooks etc. |
The process watcher has its own result type:
1 2 3 4 5 6 7 8 9 10 11 12 |
public class ProcessWatcherCheckResult : WatcherCheckResult { public ProcessInfo ProcessInfo { get; } } public class ProcessInfo { public int Id { get; } public string Name { get; } public bool Exists { get; } public bool Responding{ get; } } |
And you can provide your own implementation of the process monitoring simply bo passing the custom IProcessService into the WithProcessServiceProvider() method:
1 2 3 4 |
public interface IProcessService { Task<ProcessInfo> GetProcessInfoAsync(string name); } |
To find out a little bit more details about this watcher, please take a look at the wiki.
Pingback: Cıvata
Pingback: Astropay
Pingback: Otopay