protected virtual async Task SendAliveSignalAsync(TimeSpan interval, CancellationToken token) { while (!token.IsCancellationRequested) { await SignalRetryPolicy.ExecuteAsync((ctx, ct) => File.WriteAllTextAsync(_probeConfiguration.LivenessFilePath, DateTime.UtcNow.ToString(), ct), new Context("alive"), token).ConfigureAwait(false); LoggerInstance.LogInformation("Sent liveness signal"); await Task.Delay(interval, token).ConfigureAwait(false); } }
protected virtual async Task SendStartedSignalAsync(CancellationToken token) { await SignalRetryPolicy.ExecuteAsync(async (ctx, ct) => { var resultTasks = await Task.WhenAll(_startupActivities.Select(t => t.ExecuteAsync(ct))).ConfigureAwait(false); if (resultTasks.All(result => result)) { await File.WriteAllTextAsync(_probeConfiguration.StartupFilePath, DateTime.UtcNow.ToString(), token).ConfigureAwait(false); } }, new Context("started"), token).ConfigureAwait(false); LoggerInstance.LogInformation("Sent startup signal"); }