public EndpointJob(IServiceProvider provider, Model.Endpoint endpoint) { _provider = provider; _endpoint = endpoint; ConfigureJob(); }
public void PublishHealthReport(Model.Endpoint endpoint, HealthReport report) { if (!endpoint.PublishStats) { return; } var gauge1 = Metrics.CreateGauge($"epmon_healthcheck", "Shows health check status (0 = Unhealthy, 1 = Healthy)", new GaugeConfiguration { SuppressInitialValue = true, LabelNames = GetLabelNames() }); gauge1.WithLabels(GetLabelValues(endpoint)).Set(Convert.ToDouble(report.IsHealthy)); var gauge2 = Metrics.CreateGauge($"epmon_healthcheck_duration", "Shows duration of the health check execution in miliseconds", new GaugeConfiguration { SuppressInitialValue = true, LabelNames = GetLabelNames() }); gauge2.WithLabels(GetLabelValues(endpoint)).Set(report.ResponseTime); }
private void CreateSingle(Model.Endpoint endpoint, EndpointCreatorSettings settings) { DirectoryPath targetRootPath = new DirectoryPath(settings?.TargetRootPath ?? "./").MakeAbsolute(environment); string targetEndpointPathName = endpoint.Id + settings?.TargetPathPostFix; DirectoryPath targetEndpointPath = targetRootPath.Combine(targetEndpointPathName); if (endpoint.Files != null) { foreach (File file in endpoint.Files) { string fileSourcePath = file.SourcePath; if (!string.IsNullOrWhiteSpace(settings?.BuildConfiguration)) { fileSourcePath = fileSourcePath.Replace("[BuildConfiguration]", settings.BuildConfiguration); } if (file.IsFilePath) { FilePath targetPath = targetEndpointPath.CombineWithFilePath(file.TargetPath); context.EnsureDirectoryExists(targetPath.GetDirectory()); context.CopyFile(file.SourcePath, targetPath); } else { DirectoryPath targetPath = targetEndpointPath.Combine(file.TargetPath); context.EnsureDirectoryExists(targetPath); context.CopyFileToDirectory(fileSourcePath, targetPath); } } } if (endpoint.Directories != null) { foreach (Directory directory in endpoint.Directories) { DirectoryPath targetDirectoryPath = targetEndpointPath.Combine(directory.TargetPath); context.EnsureDirectoryExists(targetDirectoryPath); string directorySourcePath = directory.SourcePath; if (!string.IsNullOrWhiteSpace(settings?.BuildConfiguration)) { directorySourcePath = directorySourcePath.Replace("[BuildConfiguration]", settings.BuildConfiguration); } if (context.DirectoryExists(directorySourcePath)) { context.CopyDirectory(directorySourcePath, targetDirectoryPath); } else { log.Warning($"Skipped copying {directorySourcePath} because it does not exist."); } } } log.Information($"Created endpoint at {targetEndpointPath.FullPath}"); if (settings != null && settings.ZipTargetPath) { FilePath zipFilePath = targetRootPath.CombineWithFilePath(new FilePath(targetEndpointPathName + ".zip")); new Zipper(fileSystem, environment, log).Zip(targetEndpointPath, zipFilePath, context.GetFiles(string.Concat(targetEndpointPath, "/**/*"))); log.Information($"Zipped endpoint at {zipFilePath.FullPath}"); } }