public async Task StartAsync(CancellationToken cancellationToken = default) { try { // don't know why, sometimes the default network (e.g. net50_default) remains // from previous cluster and prevents docker-compose up from executing successfully Policy.Handle <FluentDockerException>() .WaitAndRetry( retryCount: 10, sleepDurationProvider: retryCount => TimeSpan.FromSeconds(2), onRetry: (ex, _) => { BuildCluster().Dispose(); _eventStoreCluster.Start(); }) .Execute(() => { _eventStoreCluster.Start(); }); await Policy.Handle <Exception>() .WaitAndRetryAsync(10, retryCount => TimeSpan.FromSeconds(2)) .ExecuteAsync(async() => { using var response = await _httpClient.GetAsync("/health/live", cancellationToken); if (response.StatusCode >= HttpStatusCode.BadRequest) { throw new Exception($"Health check failed with status code: {response.StatusCode}."); } }); } catch (Exception) { _eventStoreCluster.Dispose(); throw; } }
public void Execute(params string[] arguments) { Repository.Clone(_source, Target); var file = Path.Combine(Target, "docker-compose.yml"); // TODO: later on when swarm is supported in Fd - "docker-stack.yml" can also be selected... var files = new List <string>() { file }; if (null != _curator) { files.Add(_curator); } if (null != _logspout) { files.Add(_logspout); } if (null != _apmServer) { files.Add(_apmServer); } _svc = new DockerComposeCompositeService(_host, new DockerComposeConfig { ComposeFilePath = files, ForceRecreate = false, RemoveOrphans = false, StopOnDispose = true }); _svc.Start(); Services = new IService[] { _host, _svc }; }
public async Task InitializeAsync() { try { _eventStoreCluster.Start(); } catch (FluentDockerException) { // don't know why, sometimes the default network (e.g. net50_default) remains // from previous cluster and prevents docker-compose up from executing successfully BuildCluster().Dispose(); _eventStoreCluster.Start(); } try { using var httpClient = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = delegate { return(true); } }) { BaseAddress = new UriBuilder { Port = 2113, Scheme = Uri.UriSchemeHttps }.Uri }; await Policy.Handle <Exception>() .WaitAndRetryAsync(5, retryCount => TimeSpan.FromSeconds(retryCount * retryCount)) .ExecuteAsync(async() => { using var response = await httpClient.GetAsync("/health/live"); if (response.StatusCode >= HttpStatusCode.BadRequest) { throw new Exception($"Health check failed with status code: {response.StatusCode}."); } }); } catch (Exception) { _eventStoreCluster.Dispose(); throw; } await Connection.ConnectAsync(); }
public void Initialize() { Service = Build().Build(); try { Service.Start(); } catch { Service.Dispose(); throw; } OnServiceInitialized(); }