protected ProgramBase(string[] args) { Application.RegisterExitAction(Exit); try { var options = EventStoreOptions.Parse <TOptions>(args, Opts.EnvPrefix, Path.Combine(Locations.DefaultConfigurationDirectory, DefaultFiles.DefaultConfigFile), MutateEffectiveOptions); if (options.Help) { Console.WriteLine("Options:"); Console.WriteLine(EventStoreOptions.GetUsage <TOptions>()); _skipRun = true; } else if (options.Version) { Console.WriteLine("EventStore version {0} ({1}/{2}, {3})", VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp); _skipRun = true; } else { PreInit(options); Init(options); Create(options); _startupSource.SetResult(true); } } catch (OptionException exc) { Console.Error.WriteLine("Error while parsing options:"); Console.Error.WriteLine(FormatExceptionMessage(exc)); Console.Error.WriteLine(); Console.Error.WriteLine("Options:"); Console.Error.WriteLine(EventStoreOptions.GetUsage <TOptions>()); _startupSource.SetException(exc); } catch (ApplicationInitializationException ex) { var msg = String.Format("Application initialization error: {0}", FormatExceptionMessage(ex)); if (LogManager.Initialized) { Log.FatalException(ex, msg); } else { Console.Error.WriteLine(msg); } _startupSource.SetException(ex); } catch (Exception ex) { var msg = "Unhandled exception while starting application:"; if (LogManager.Initialized) { Log.FatalException(ex, msg); } else { Console.Error.WriteLine(msg); Console.Error.WriteLine(FormatExceptionMessage(ex)); } _startupSource.SetException(ex); } finally { Log.Flush(); } }
protected EventStoreHostedService(string[] args) { try { Options = EventStoreOptions.Parse <TOptions>(args, Opts.EnvPrefix, Path.Combine(Locations.DefaultConfigurationDirectory, DefaultFiles.DefaultConfigFile), MutateEffectiveOptions); if (Options.Help) { Console.WriteLine("Options:"); Console.WriteLine(EventStoreOptions.GetUsage <TOptions>()); _skipRun = true; } else if (Options.Version) { Console.WriteLine("EventStore 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) { Console.Error.WriteLine("Error while parsing options:"); Console.Error.WriteLine(FormatExceptionMessage(exc)); Console.Error.WriteLine(); Console.Error.WriteLine("Options:"); Console.Error.WriteLine(EventStoreOptions.GetUsage <TOptions>()); throw; } }
public int Run(string[] args) { try { Application.RegisterExitAction(Exit); var options = EventStoreOptions.Parse <TOptions>(args, Opts.EnvPrefix, Path.Combine(Locations.DefaultConfigurationDirectory, DefaultFiles.DefaultConfigFile)); if (options.Help) { Console.WriteLine("Options:"); Console.WriteLine(EventStoreOptions.GetUsage <TOptions>()); } else if (options.Version) { Console.WriteLine("EventStore version {0} ({1}/{2}, {3})", VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp); Application.ExitSilent(0, "Normal exit."); } else { PreInit(options); Init(options); CommitSuicideIfInBoehmOrOnBadVersionsOfMono(options); Create(options); Start(); _exitEvent.Wait(); } } catch (OptionException exc) { Console.Error.WriteLine("Error while parsing options:"); Console.Error.WriteLine(FormatExceptionMessage(exc)); Console.Error.WriteLine(); Console.Error.WriteLine("Options:"); Console.Error.WriteLine(EventStoreOptions.GetUsage <TOptions>()); } catch (ApplicationInitializationException ex) { Log.FatalException(ex, "Application initialization error: {0}", FormatExceptionMessage(ex)); Application.Exit(ExitCode.Error, FormatExceptionMessage(ex)); } catch (Exception ex) { Console.WriteLine(ex); Log.FatalException(ex, "Unhandled exception while starting application:\n{0}", FormatExceptionMessage(ex)); Application.Exit(ExitCode.Error, FormatExceptionMessage(ex)); } finally { Log.Flush(); } Application.ExitSilent(_exitCode, "Normal exit."); return(_exitCode); }
protected EventStoreHostedService(string[] args) { try { _args = args; Options = LoadConfig(); 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; } }