public EventStoreService(IPAddress address, EventStoreServiceConfiguration configuration) { this.address = address; this.configuration = configuration; this.processes = new Dictionary<Process, Tuple<string, DateTime>>(); this.eventStorePath = this.GetEventStorePath(configuration); this.restartDelay = this.GetRestartDelay(configuration); this.restartWindow = this.GetRestartWindow(configuration); this.DumpConfig(); }
private TimeSpan GetRestartWindow(EventStoreServiceConfiguration config) { var windowInMs = config.RestartWindowMs.HasValue ? config.RestartWindowMs.Value : 1000 * 30; return new TimeSpan(0, 0, 0, 0, windowInMs); }
private string GetEventStorePath(EventStoreServiceConfiguration config) { var configPath = config.EventStorePath; if (string.IsNullOrWhiteSpace(configPath)) { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "eventstore", ExecutableName); } if (Path.IsPathRooted(configPath)) { return configPath; } return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configPath, ExecutableName); }
private int GetRestartDelay(EventStoreServiceConfiguration config) { return config.RestartDelayMs.HasValue ? config.RestartDelayMs.Value : 1000 * 3; }
private string BuildNodeArguments( InternalNode currentNode, EventStoreServiceConfiguration configuration, int nodeCount, IPAddress detectedIpAddress) { // Based on https://github.com/eventstore/eventstore/wiki/Setting-Up-OSS-Cluster var builder = new StringBuilder(); var internalIpAddress = GetInternalIpAddress(currentNode, detectedIpAddress); var externalIpAddress = GetExternalIpAddress(currentNode, detectedIpAddress); builder.AppendFormat("--db={0} ", currentNode.DbPath); builder.AppendFormat("--log={0} ", currentNode.LogPath); builder.AppendFormat("--int-ip={0} ", internalIpAddress); builder.AppendFormat("--ext-ip={0} ", externalIpAddress); if (!string.IsNullOrWhiteSpace(currentNode.IntHttpPrefixes)) { builder.AppendFormat("--int-http-prefixes={0} ", currentNode.IntHttpPrefixes); } if (!string.IsNullOrWhiteSpace(currentNode.ExtHttpPrefixes)) { builder.AppendFormat("--ext-http-prefixes={0} ", currentNode.ExtHttpPrefixes); } builder.AppendFormat("--int-tcp-port={0} ", currentNode.IntTcpPort); builder.AppendFormat("--ext-tcp-port={0} ", currentNode.ExtTcpPort); builder.AppendFormat("--int-http-port={0} ", currentNode.IntHttpPort); builder.AppendFormat("--ext-http-port={0} ", currentNode.ExtHttpPort); builder.AppendFormat(" {0} {1} ", configuration.AdditionalFlags, currentNode.AdditionalFlags); builder.AppendFormat("--cluster-size={0} ", nodeCount); builder.AppendFormat("--discover-via-dns=false "); var intGossipNodes = configuration.InternalNodes.Cast<InternalNode>().Where(n => !ReferenceEquals(n, currentNode)).Select(n => String.Format("{0}:{1}", GetInternalIpAddress(n, detectedIpAddress), n.IntHttpPort)); var extGossipNodes = configuration.ExternalNodes.Cast<ExternalNode>().Select(n => String.Format("--gossip-seed={0}:{1}", n.IpAddress, n.GossipPort)); var gossipNodes = intGossipNodes.Union(extGossipNodes).ToArray(); if (gossipNodes.Any()) { builder.AppendFormat("--gossip-seed={0}", String.Join(",", gossipNodes)); } return builder.ToString(); }