Exemple #1
0
        public void Execute(string[] args)
        {
            if (args != null && args.Contains("--no-http-bootstrap"))
            {
                _logger.Warning("HTTP bootstrapping disabled. No plugins will be downloaded.");
                return;
            }

            if (_configuration.HasDownloadedCorePluginPackages ||
                _configuration.CorePluginPackages == null ||
                !_configuration.CorePluginPackages.Any())
            {
                _logger.Information("Core packages already installed, or no packages specified.");
                return;
            }

            var packages = _configuration.CorePluginPackages.ToList();

            _logger.Information("Installing core packages {Packages}.", packages);

            foreach (var packageId in packages)
            {
                // Find latest version of packageId
                var package = _packageRepository.FindPackage(packageId);

                if (package == null)
                {
                    continue;
                }

                _packageManager.InstallPackage(package, false, false);
            }

            _configuration.HasDownloadedCorePluginPackages = true;
            _configuration.Save();
        }
Exemple #2
0
        public async Task When()
        {
            using (var conn = TestConnection.Create(_node.TcpEndPoint, TcpType.Ssl, DefaultData.AdminCredentials)) {
                await conn.ConnectAsync();

                var countdown = new CountdownEvent(2);
                _result = new List <ResolvedEvent>();

                conn.SubscribeToStreamFrom(SystemStreams.ScavengesStream, null, CatchUpSubscriptionSettings.Default,
                                           (x, y) => {
                    _result.Add(y);
                    countdown.Signal();
                    return(Task.CompletedTask);
                },
                                           _ => Log.Information("Processing events started."),
                                           (x, y, z) => { Log.Information("Subscription dropped: {0}, {1}.", y, z); }
                                           );

                if (!countdown.Wait(Timeout))
                {
                    Assert.Fail("Timeout expired while waiting for events.");
                }
            }
        }
Exemple #3
0
 public static T Deserialize <T>(this ArraySegment <byte> data) where T : IMessage <T>, new()
 {
     try {
         using (var memory = new MemoryStream(data.Array, data.Offset, data.Count)
                )          //uses original buffer as memory
         {
             var res = new T();
             res.MergeFrom(memory);
             return(res);
         }
     } catch (Exception e) {
         Log.Information(e, "Deserialization to {type} failed", typeof(T).FullName);
         return(default(T));
     }
 }
        protected EventStoreCache(IObservable<IConnected<IEventStoreConnection>> eventStoreConnectionStream, ILogger log)
        {
            _log = log;
            Disposables = new CompositeDisposable(_eventsConnection, _eventsSubscription);

            _connectionChanged = eventStoreConnectionStream.ObserveOn(_eventLoopScheduler)
                                                           .Publish();

            Disposables.Add(_connectionChanged.Connect());

            Disposables.Add(_connectionChanged.Subscribe(x =>
            {
                if (x.IsConnected)
                {
                    if (_log.IsEnabled(LogEventLevel.Information))
                    {
                        _log.Information("Connected to Event Store");
                    }

                    Initialize(x.Value);
                }
                else
                {
                    if (_log.IsEnabled(LogEventLevel.Information))
                    {
                        _log.Information("Disconnected from Event Store");
                    }

                    if (!_stateOfTheWorldContainer.IsStale)
                    {
                        _stateOfTheWorldContainer.IsStale = true;
                        _stateOfTheWorldUpdates.OnNext(_stateOfTheWorldContainer);
                    }
                }
            }));
        }
Exemple #5
0
        public void BuildPackage(string basePath, IList <string> includes, ManifestMetadata metadata, string outFolder, bool overwrite, bool verboseInfo)
        {
            var filename = metadata.Id + "." + metadata.Version + ".zip";
            var output   = fileSystem.GetFullPath(Path.Combine(outFolder, filename));

            if (fileSystem.FileExists(output) && !overwrite)
            {
                throw new CommandException("The package file already exists and --overwrite was not specified");
            }

            log.Information("Saving {Filename} to {OutFolder}...", filename, outFolder);

            fileSystem.EnsureDirectoryExists(outFolder);

            var logLevel       = verboseInfo ? LogEventLevel.Verbose : LogEventLevel.Debug;
            var basePathLength = fileSystem.GetFullPath(basePath).Length;

            using (var stream = fileSystem.OpenFile(output, FileAccess.Write))
                using (var archive = new ZipArchive(stream, ZipArchiveMode.Create))
                {
                    foreach (var pattern in includes)
                    {
                        log.Debug("Adding files from {Path} matching pattern {Pattern}", basePath, pattern);
                        foreach (var file in PathResolver.PerformWildcardSearch(basePath, pattern))
                        {
                            var fullFilePath = fileSystem.GetFullPath(file);
                            if (string.Equals(fullFilePath, output, StringComparison.CurrentCultureIgnoreCase))
                            {
                                continue;
                            }

                            var relativePath = UseCrossPlatformDirectorySeparator(
                                fullFilePath.Substring(basePathLength).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));

                            log.Write(logLevel, "Added file: {relativePath}");

                            var entry = archive.CreateEntry(relativePath, CompressionLevel.Optimal);
                            entry.LastWriteTime = new DateTimeOffset(new FileInfo(file).LastWriteTime);

                            using (var entryStream = entry.Open())
                                using (var sourceStream = File.OpenRead(file))
                                {
                                    sourceStream.CopyTo(entryStream);
                                }
                        }
                    }
                }
        }
Exemple #6
0
            private async Task OnReadEvent(IStreamSubscription arg1, ResolvedEvent arg2, CancellationToken t)
            {
                var(m, ev) = _converter.Convert <TEvent>(arg2);
                var groupName = typeof(TEvent).FullName.Replace(".", "-");

                try
                {
                    await _connection.Clients.All.SendCoreAsync(groupName, new object[] { m, ev });

                    Log.Information("SignalR hub send event {eventName} to it's clients.", typeof(TEvent).Name);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
Exemple #7
0
        protected DittoWebSocketManager(string ns, string type, string uri, string username, string password)
        {
            // Serilog Configuration
            Log = Processor.Log.CreateLog(type);

            blKeepRunning = true;
            ewh           = new AutoResetEvent(false);
            // Start new read thread
            cts = new CancellationTokenSource();
            CancellationToken ct = cts.Token;

            // Initiate Configuration
            conf = new Configuration.Connection(uri, username, password);
            Log.Information("Starting new task to connect to Ditto Websocket...");
            t = Task.Factory.StartNew(() => Start(ns), ct);
        }
Exemple #8
0
        public BaseViewModel(IScreen hostScreen = null)
        {
            Log        = Serilog.Log.ForContext(GetType());
            HostScreen = hostScreen ?? Locator.Current.GetService <IScreen>();

            _isVisibleSubject = new BehaviorSubject <bool>(false);
            Log.Information($"Instatiated: {GetType().Name}");
            this.WhenActivated(disposables =>
            {
                HandleActivation();

                Disposable
                .Create(HandleDeactivation)
                .DisposeWith(disposables);
            });
        }
Exemple #9
0
        public IActionResult Index(string shortCode)
        {
            _logger.Debug("Entered the redirect for short code {shortCode}", shortCode);
            var redirectItem = _shortLinkRepo.GetByShortCode(shortCode);

            if (string.IsNullOrWhiteSpace(redirectItem?.URL))
            {
                _logger.Warning("No redirect found for requested short code {shortCode}", shortCode);
                return(View("NotFound"));
            }

            _logger.Information("Redirecting {shortCode} to {redirectUrl} using tracking Id {gaTrackingId}", redirectItem.ShortLinkCode, redirectItem.URL, _gaOptions.TrackingPropertyId);
            var viewModel = new RedirectViewModel(_gaOptions.TrackingPropertyId, _redirectOptions.SecondsToWaitForAnalytics, shortCode, redirectItem.URL);

            return(View("Index", viewModel));
        }
        private static void ConfigureDynamics(IServiceCollection services, ProjectConfiguration project, ProjectResource projectResource, Serilog.ILogger logger)
        {
            Debug.Assert(services != null, "Required ServiceCollection is null");
            Debug.Assert(project != null, "Required ProjectConfiguration is null");
            Debug.Assert(projectResource != null, "Required ProjectResource is null");
            Debug.Assert(projectResource.Type == ProjectType.Dynamics, "Project type must be Dynamics");

            // the projectResourceKey convention is repeated also in OAuthClientFactory which gets the HttpClient using the same convention,
            //
            // {Id}-dynamics-authorization
            //
            string projectResourceKey = project.Id + "-dynamics";

            // add authorization HttpClient
            services.AddHttpClient(projectResourceKey + "-authorization", configure => configure.BaseAddress = projectResource.AuthorizationUri)
            ;

            // add odata HttpClient
            // note: I do not like this IoC anti-pattern where we are using the service locator directly, however,
            //       there are many named dependencies. There may be an opportunity to address this in the future

            var builder = services.AddHttpClient(projectResourceKey, configure =>
            {
                configure.BaseAddress = projectResource.Resource;
            })
                          .AddHttpMessageHandler(serviceProvider =>
            {
                // build the token service that talk to the OAuth endpoint
                IOAuthClientFactory oauthClientFactory = serviceProvider.GetRequiredService <IOAuthClientFactory>();
                IOAuthClient client = oauthClientFactory.Create(project);
                ITokenCache <OAuthOptions, Token> tokenCache = serviceProvider.GetRequiredService <ITokenCache <OAuthOptions, Token> >();

                ITokenService tokenService = new OAuthTokenService(client, tokenCache);
                var handler = new TokenAuthorizationHandler(tokenService, CreateOAuthOptions(projectResource));
                return(handler);
            });

            var apiGatewayHost   = projectResource.ApiGatewayHost;
            var apiGatewayPolicy = projectResource.ApiGatewayPolicy;

            if (!string.IsNullOrEmpty(apiGatewayHost) && !string.IsNullOrEmpty(apiGatewayPolicy))
            {
                // add the ApiGatewayHandler
                logger.Information("Using {@ApiGateway} for {Resource}", new { Host = apiGatewayHost, Policy = apiGatewayPolicy }, projectResource.Resource);
                builder.AddHttpMessageHandler(() => new ApiGatewayHandler(apiGatewayHost, apiGatewayPolicy));
            }
        }
        public async Task <IEnumerable <OutputMapping1GetListValues> > GetRemedyChangedWorkItems(DateTime fromUtc)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            try
            {
                var authInfo = new AuthenticationInfo()
                {
                    userName       = _options.ServiceUserName,
                    password       = _options.ServicePassword,
                    authentication = "?",
                    locale         = "?",
                    timeZone       = "?"
                };

                var remedyResponse = await _remedyClient.New_Get_Operation_0Async(
                    new New_Get_Operation_0Request(
                        authInfo,
                        _options.TemplateName,
                        fromUtc.ToString("O"))); // TODO: apply time component - like format "O" or "yyyy-MM-dd"

                int count = 0;
                if (remedyResponse != null && remedyResponse.getListValues != null)
                {
                    count = remedyResponse.getListValues.Length;
                }
                _logger.Information($"Remedy returned { count } changed work item records in { watch.Elapsed.TotalMilliseconds }ms");

                return(remedyResponse.getListValues);
            }
            catch (Exception err)
            {
                // need to find a better way to detect this...
                if (err.Message.StartsWith("ERROR (302): Entry does not exist in database"))
                {
                    // none found, so return empty list
                    return(new OutputMapping1GetListValues[] { });
                }
                else
                {
                    _logger.Error(err, $"Unable to get response from Remedy: { err.Message }");
                    throw;
                }
            }
        }
        private async Task <List <IRecord> > RunAsync(string cypherQuery)
        {
            _logger.Information(cypherQuery);

            var session = _driver.AsyncSession();

            try
            {
                var result = await session.RunAsync(cypherQuery);

                return(await result.ToListAsync());
            }
            finally
            {
                await session.CloseAsync();
            }
        }
Exemple #13
0
        public async Task <int> RunAsync([NotNull] params string[] args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            _logger.Information("Starting Arbor.SyslogServer");

            WebHost = HostBuilder.Build();

            await WebHost.StartAsync(_cancellationTokenSource.Token);

            _logger.Debug("Started webhost");

            return(0);
        }
        /// <summary>
        /// Shows progress information is enumerating takes longer
        /// </summary>
        /// <param name="e"></param>
        /// <param name="metric"></param>
        /// <param name="updateInterval"></param>
        /// <param name="metricUnit"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public static IEnumerable <T> Progress <T>(this IEnumerable <T> e,
                                                   Func <T, double> metric = null,
                                                   TimeSpan updateInterval = default(TimeSpan),
                                                   string metricUnit       = null,
                                                   string description      = null
                                                   )
        {
            if (description == null)
            {
                description = String.Empty;
            }
            else
            {
                description = description + " ";
            }
            if (metric == null)
            {
                metric = (item) => 1.0;
            }
            if (updateInterval == default(TimeSpan))
            {
                updateInterval = TimeSpan.FromSeconds(2);
            }
            if (metricUnit == null)
            {
                metricUnit = String.Empty;
            }
            Func <double, string> format = (double x) => x.MetricShort();

            var speedUnit = $"{metricUnit}/s";

            var progress = ToProgress((ProgressUpdate <T> p) =>
            {
                Logger.Information("{description}{total}{unit} complete, {speed}{speedUnit}: {item}",
                                   description,
                                   format(p.Total),
                                   metricUnit,
                                   format(p.Speed),
                                   speedUnit, p.Current);
            });

            return(e.Progress(progress,
                              metric: metric,
                              updateInterval: updateInterval
                              ));
        }
        public bool Acquire()
        {
            if (_acquired)
            {
                throw new InvalidOperationException(string.Format("DB mutex '{0}' is already acquired.", MutexName));
            }

            try {
                _dbMutex = new Mutex(initiallyOwned: true, name: MutexName, createdNew: out _acquired);
            } catch (AbandonedMutexException exc) {
                Log.Information(exc,
                                "DB mutex '{mutex}' is said to be abandoned. "
                                + "Probably previous instance of server was terminated abruptly.",
                                MutexName);
            }

            return(_acquired);
        }
Exemple #16
0
        protected BaseJobRunner(
            TraffkGlobalDbContext globalContext,
            IJobInfoFinder jobInfoFinder,
            ILogger logger)
        {
            GlobalContext = globalContext;
            InstanceId    = Interlocked.Increment(ref InstanceId_s);
            JobInfo       = jobInfoFinder.JobInfo;

            Logger = logger.ForContext(new ILogEventEnricher[]
            {
                new PropertyEnricher(nameof(InstanceId), InstanceId),
                new PropertyEnricher(nameof(JobInfo.JobId), JobInfo?.JobId),
                new PropertyEnricher(typeof(Type).Name, GetType().Name),
            });

            Logger.Information(ConstructedText);
        }
Exemple #17
0
        public void Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime, IHostingEnvironment env)
        {
            _logger = app.ApplicationServices.GetService <Serilog.ILogger>();

            app.UseMvc();
            app.Run(async context =>
            {
                var message = "Invalid route: " + context.Request.Path;
                _logger.Information(message);
                context.Response.StatusCode = 404;
                await context.Response.WriteAsync(message);
            });

            var host = app.ApplicationServices.GetService <PizzaServiceHost>();

            applicationLifetime.ApplicationStarted.Register(async() => await host.Start());
            applicationLifetime.ApplicationStopping.Register(host.Stop);
        }
        public static IServiceCollection AddSesEmailConfiguration(this IServiceCollection services, IConfiguration configuration, ILogger logger)
        {
            if (!string.IsNullOrEmpty(configuration["ses:accessKey"]) &&
                !string.IsNullOrEmpty(configuration["ses:secretKey"]))
            {
                var amazonSesKeys = new AmazonSESKeys(configuration["ses:accessKey"], configuration["ses:secretKey"]);
                services.AddSingleton(amazonSesKeys);
                var credentals = new BasicAWSCredentials(amazonSesKeys.Accesskey, amazonSesKeys.SecretKey);
                services.AddTransient <IAmazonSimpleEmailService>(
                    o => new AmazonSimpleEmailServiceClient(credentals, RegionEndpoint.EUWest1));
            }
            else
            {
                logger.Information("Secrets not found.");
            }

            return(services);
        }
Exemple #19
0
        public async Task PublishAsync(IntegrationEvent @event)
        {
            if (!_persistentConnection.IsConnected)
            {
                _persistentConnection.TryConnect();
            }

            var eventName = @event.GetType().Name;

            _logger.Information("Creating RabbitMQ channel to publish event: {0} {1})", @event.Id, eventName);

            try
            {
                using (var channel = _persistentConnection.CreateModel())
                {
                    _logger.Information("Declaring RabbitMQ exchange to publish event: {0}", @event.Id);

                    channel.ExchangeDeclare(exchange: BROKER_NAME, ExchangeType.Direct);
                    channel.QueueBind(_queueName, BROKER_NAME, eventName);

                    var message = JsonConvert.SerializeObject(@event);
                    var body    = Encoding.UTF8.GetBytes(message);

                    await _retryPolicy.ExecuteAsync(async() =>
                    {
                        var properties          = channel.CreateBasicProperties();
                        properties.DeliveryMode = 2; // persistent

                        _logger.Information("Publishing event to RabbitMQ: {0}", @event.Id);

                        channel.BasicPublish(exchange: BROKER_NAME, routingKey: eventName, mandatory: true,
                                             basicProperties: properties, body: body);
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Could not publish event: {0} after  ({1})", @event.Id, ex.Message);
                throw;
            }
        }
Exemple #20
0
 public virtual Task <GitVersion.VersionVariables> GetVersion()
 {
     return(Task.Factory.StartNew(() =>
     {
         var gitVersionExecuteCore = new GitVersion.ExecuteCore(new GitVersion.Helpers.FileSystem());
         string templateString = @"GitVersion: {message}";
         GitVersion.Logger.SetLoggers(
             _ => Logger.Debug(templateString, _),
             _ => Logger.Debug(templateString, _),
             _ => Logger.Warning(templateString, _),
             _ => Logger.Error(templateString, _));
         if (!gitVersionExecuteCore.TryGetVersion(RootDirectory, out var versionVariables, true, null))
         {
             throw new System.Exception("Cannot read version");
         }
         Logger.Information("GitVersion: {InformationalVersion}", versionVariables.InformationalVersion);
         return versionVariables;
     }, TaskCreationOptions.LongRunning));
 }
        private void HandleSaveConfigurationCompleted(Action continueWith, ClientMessage.WriteEventsCompleted obj)
        {
            switch (obj.Result)
            {
            case OperationResult.Success:
                continueWith();
                break;

            case OperationResult.CommitTimeout:
            case OperationResult.PrepareTimeout:
                Log.Information("Timeout while trying to save persistent subscription configuration. Retrying");
                SaveConfiguration(continueWith);
                break;

            default:
                throw new Exception(obj.Result +
                                    " is an unexpected result writing persistent subscription configuration.");
            }
        }
Exemple #22
0
        public Task PublishAsync(HealthReport report, CancellationToken cancellationToken)
        {
            if (report.Status == HealthStatus.Healthy)
            {
                _serilog.Information("{Timestamp} Readiness Probe Status: {Result}",
                                     DateTime.UtcNow, report.Status);
            }
            else
            {
                _serilog.Error("{Timestamp} Readiness Probe Status: {Result}",
                               DateTime.UtcNow, report.Status);

                ReportEntriesAsError(report);
            }

            cancellationToken.ThrowIfCancellationRequested();

            return(Task.CompletedTask);
        }
Exemple #23
0
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            var messageFormat = formatter(state, exception);

            switch (logLevel)
            {
            case LogLevel.Error:
                logger.Error(messageFormat);
                break;

            case LogLevel.Information:
                logger.Information(messageFormat);
                break;

            case LogLevel.Warning:
                logger.Warning(messageFormat);
                break;
            }
        }
        public static IServiceCollection AddGroupConfiguration(this IServiceCollection services, IConfiguration configuration, ILogger logger)
        {
            if (!string.IsNullOrEmpty(configuration["group:authenticationKey"]))
            {
                var groupKeys = new GroupAuthenticationKeys {
                    Key = configuration["group:authenticationKey"]
                };
                services.AddSingleton(groupKeys);

                services.AddScoped(p => new GroupAuthorisation(p.GetService <IApplicationConfiguration>(), p.GetService <ILoggedInHelper>()));

                services.AddSingleton <IJwtDecoder>(p => new JwtDecoder(p.GetService <GroupAuthenticationKeys>(), p.GetService <ILogger <JwtDecoder> >()));
            }
            else
            {
                logger.Information("Group authenticationKey not found.");
            }

            return(services);
        }
        public Task StartAsync(CancellationToken cancellationToken)
        {
            Logger.Information($"Starting proto cluster node on {_nodeAddress}:{_nodePort}");

            Serialization.RegisterFileDescriptor(CommandsReflection.Descriptor);

            var eventStoreProvider = new EventStoreProvider(_eventStoreConnection)
                                     .WithTypeResolver(
                t => TypeMapper.GetTypeName(t),
                s => Type.GetType(s));

            var measuredStore = new MeasuredActorStore(eventStoreProvider);

            Remote.RegisterKnownKind("Vehicle",
                                     Props.FromProducer(() => new VehicleActor(measuredStore))
                                     .WithReceiverMiddleware(next => Middleware.Metrics(next, "Vehicle")));

            Cluster.Start(_clusterName, _nodeAddress, _nodePort, _consulProvider);
            return(Task.CompletedTask);
        }
Exemple #26
0
        public void Log(string message, LogLevel logLevel)
        {
            switch (logLevel)
            {
            case LogLevel.Information:
                _serilog.Information(message);
                break;

            case LogLevel.Error:
                _serilog.Error(message);
                break;

            case LogLevel.Fatal:
                _serilog.Fatal(message);
                break;

            default:
                break;
            }
        }
        public async Task <EventEnvelope[]> Append(Guid key, ulong version, Guid correlationId, IEnumerable <IEvent> published)
        {
            var streamName     = GetStreamName(key);
            var publishedArray = published as IEvent[] ?? published.ToArray();

            EventEnvelope[] data = new EventEnvelope[publishedArray.Length];

            for (ulong i = 0; i < (ulong)publishedArray.Length; i++)
            {
                var ev = publishedArray[i];
                data[i] = new EventEnvelope(ev, _metadataFactory.Create(key, correlationId, ev, version + i));
            }
            var evData = data.Select(_eventDataFactory.Create);

            await _connection.AppendToStreamAsync(streamName, new StreamRevision(version), evData);


            _logger.Information("Writing event to stream {streamName} {eventNames}", streamName, publishedArray.Select(x => x.GetType().Name).ToArray());
            return(data);
        }
Exemple #28
0
        private void CompleteInterruptedScavenges(IList <string> incompletedScavenges)
        {
            if (incompletedScavenges.Count == 0)
            {
                Log.Debug("No incomplete scavenges found on node {nodeEndPoint}.", _nodeEndpoint);
            }
            else
            {
                Log.Information(
                    "Found {incomplete} incomplete scavenge{s} on node {nodeEndPoint}. Marking as failed:{newLine}{incompleteScavenges}",
                    incompletedScavenges.Count, incompletedScavenges.Count == 1 ? "" : "s", _nodeEndpoint,
                    Environment.NewLine, string.Join(Environment.NewLine, incompletedScavenges));
            }

            foreach (var incompletedScavenge in incompletedScavenges)
            {
                var log = CreateLogInternal(incompletedScavenge);

                log.ScavengeCompleted(ScavengeResult.Failed, "The node was restarted.", TimeSpan.Zero);
            }
        }
 protected EventStoreHostedService(string[] args)
 {
     try {
         Options = EventStoreOptions.Parse <TOptions>(args, Opts.EnvPrefix,
                                                      Path.Combine(Locations.DefaultConfigurationDirectory, DefaultFiles.DefaultConfigFile),
                                                      MutateEffectiveOptions);
         if (Options.Help)
         {
             Console.WriteLine("EventStoreDB version {0} ({1}/{2}, {3})",
                               VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp);
             Console.WriteLine();
             Console.WriteLine(EventStoreOptions.GetUsage <TOptions>());
             _skipRun = true;
         }
         else if (Options.Version)
         {
             Console.WriteLine("EventStoreDB version {0} ({1}/{2}, {3})",
                               VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp);
             _skipRun = true;
         }
         else
         {
             PreInit(Options);
             Init(Options);
             Create(Options);
         }
     } catch (OptionException exc) {
         Log.Error("Error while parsing options:");
         Log.Error(FormatExceptionMessage(exc));
         Log.Information("Options:");
         Log.Information(EventStoreOptions.GetUsage <TOptions>());
         _skipRun = true;
     } catch (InvalidConfigurationException exc) {
         Log.Error("Invalid Configuration Encountered");
         Log.Error(exc.Message);
         _skipRun = true;
     }
 }
        public async Task Handle(InitiativeStatusDescriptionUpdatedDomainEvent notification, CancellationToken cancellationToken)
        {
            _logger.Debug("Initiative Status Description changed, will post message to service bus");
            var initiative = await _initiativeRepository.GetInitiativeAsync(notification.InitiativeId);

            if (initiative == null)
            {
                _logger.Error("Received new initiave event but couldn't get initiative with id {InitiativeUid}", notification.InitiativeId);
                throw new Exception($"Received new initiave event but couldn't get initiative with id {notification.InitiativeId}");
            }
            else
            {
                _logger.Information("Posting StatusDescriptionChanged event to service bus for Initiative {InitiativeId}", initiative.Id);
            }

            await _initiativeMessageSender.SendInitiativeStatusDescriptionChangedAsync(new InitiativeStatusDescriptionChangedEventArgs()
            {
                Initiative = initiative,
                Owner      = _currentUserAccessor.User
            });
        }