Пример #1
0
        private int?GetOrphanedProcessId(string host)
        {
            var headers = new Dictionary <string, string> {
                { "host", host }, { ProcessManagementConstants.ProcessManagerHeader, _uuid }
            };
            var response = _httpClient.GetAsync <string, string>($"/{ProcessManagementConstants.PROCESS_MANAGEMENT_ROUTE_PREFIX}/id", headers).Result;
            int processId;
            var isInt = int.TryParse(response.Result, out processId);

            if (!isInt)
            {
                return(null);
            }
            return(processId);
        }
Пример #2
0
        private HealthCheckResult DoHealthCheck()
        {
            var headers = new Dictionary <string, string> {
                { ProcessManagementConstants.ProcessManagerHeader, "81d9a0c0-832f-4ac9-beff-60602810d452" }
            };
            var response = _processManagerApiClient.GetAsync <string, string>($"/{ProcessManagementConstants.HEALTH_CHECK_ROUTE_PREFIX}", headers).Result;

            var isHealthy =
                response.HttpStatusCode == HttpStatusCode.OK &&
                response.Result.Contains("(master)");

            return(new HealthCheckResult
            {
                IsHealthy = isHealthy,
                HttpResult = response
            });
        }
Пример #3
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider, IApplicationLifetime appLifetime, IProcessManagerApiClient processManagerApiClient, IProcessManager processManager)
        {
            _serviceProvider = serviceProvider;

            app.UseExceptionHandler();
            app.UseHealthCheck();
            app.UseProcessManagement();

            app.Run(async context =>
            {
                await context.Response.WriteAsync("Test Response");
            });

            appLifetime.ApplicationStarted.Register(() =>
            {
                var headers = new Dictionary <string, string> {
                    { ProcessManagementConstants.ProcessManagerHeader, processManager.GetUUID() }
                };

                processManagerApiClient.GetAsync <string, string>($"/{ProcessManagementConstants.PROCESS_MANAGEMENT_ROUTE_PREFIX}/event/?eventId=0", headers);
            });
        }