public static int Main(string[] args) { Directory.SetCurrentDirectory(AssemblyDirectory); LoggingInitializer.ConfigureLogging(args); Presenter.ShowApplicationHeading(Logger, Assembly.GetEntryAssembly().GetName().Version, args); var clientFactory = CreateClientFactory(); var runner = CreateRunner(clientFactory); var arguments = runner.ParseArguments(args); if (arguments != null) { if (arguments.HasArgumentLabeled("on:")) { var hostname = arguments.FindValueFromLabel("on:").Value; Presenter.ShowMessage($"on node: {hostname}", Logger); clientFactory.Hostname = hostname; } var returnValue = runner.RunProgram(arguments); Logger.Debug("Finishing cafe run"); return(returnValue); } else { Presenter.ShowError("No options match the supplied arguments. Run cafe help to view all options", Logger); return(-2); } }
protected IntegrationTestFixture() { LoggingInitializer.Initialize(); var configuration = InitializeConfiguration(); _container = InitializeContainer(configuration); // InitializeDatabase(); }
public ProgramLoader( string path, IEnumerable <string> args, string workingDir) { _path = Path.GetFullPath(path); _workingDir = Path.GetFullPath(workingDir ?? Directory.GetCurrentDirectory()); _args = args.ToArray(); _loggingInitializer = new LoggingInitializer(); _log = LogManager.GetLogger <ProgramLoader>(); }
public static int Main(string[] args) { Directory.SetCurrentDirectory(AssemblyDirectory); LoggingInitializer.ConfigureLogging(args); const string application = "cafe.Updater"; var processExecutor = new ProcessExecutor(() => new ProcessBoundary()); IWin32Service ServiceFactory() => new CafeUpdaterWindowsService(new CafeInstaller( new FileSystemCommandsBoundary(), processExecutor, UpdaterSettings.Instance.CafeApplicationDirectory)); var runner = new OptionGroup() .WithGroup("server", serverGroup => { serverGroup.WithDefaultOption(new ServerInteractiveOption(application, ServiceFactory)); serverGroup.WithOption(new ServerWindowsServiceOption(application, ServiceFactory), "--run-as-service"); }) .WithGroup("service", serviceGroup => { var fileSystem = new FileSystem(new EnvironmentBoundary(), new FileSystemCommandsBoundary()); var serviceStatusWaiter = new ServiceStatusWaiter("waiting for service status", new AutoResetEventBoundary(), new TimerFactory(), new ServiceStatusProvider(processExecutor, fileSystem), application); ServiceOptionInitializer.AddServiceOptionsTo(serviceGroup, serviceStatusWaiter, processExecutor, fileSystem, application, "cafe Updater", "updates cafe"); }) .WithOption(new WaitForInstallOption(new FileSystemCommandsBoundary()), OptionValueSpecification.ForCommand("wait"), OptionValueSpecification.ForValue("installer:", "the name of the installer file that should be processed by the updater")); var arguments = runner.ParseArguments(args); if (arguments != null) { var returnValue = runner.RunProgram(arguments); Logger.Debug($"Finishing {application} run"); return(returnValue); } else { Presenter.ShowError( $"No options match the supplied arguments. Run {application} help to view all options", Logger); return(-2); } }
public static async Task Main(string[] args) { var logging = new LoggingInitializer(); var log = LogManager.GetLogger <Program>(); try { var brokerPath = args.Length > 0 ? args[0] : Path.GetFullPath(@"../.."); Console.WriteLine("Connecting to broker {0}", brokerPath); var client = ClientFactory.Instance.Create( new ClientOptionsBuilder() .WithDefaultConfiguration(brokerPath) .WithApplicationId("interop.samples.GreetingServer") .WithProvidedService( "interop.samples.GreetingService", s => s .WithUnaryMethod <GreetingRequest, GreetingResponse>("Unary", GreetingUnary) .WithServerStreamingMethod <GreetingRequest, GreetingResponse>("ServerStreaming", GreetingServerStreaming) .WithClientStreamingMethod <GreetingRequest, GreetingResponse>("ClientStreaming", GreetingClientStreaming) .WithDuplexStreamingMethod <GreetingRequest, GreetingResponse>("DuplexStreaming", GreetingDuplexStreaming) ) .Build()); Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; Console.WriteLine("Disconnecting"); client.DisconnectAsync(); }; await client.ConnectAsync().ConfigureAwait(false); Console.WriteLine("Connected"); await client.Completion; Console.WriteLine("Disconnected"); } catch (Exception ex) { Console.WriteLine("Program terminated with exception. See log for details. {0}: {1}", ex.GetType(), ex.Message); log.Error(ex, "Program terminated with exception"); logging.Dispose(); } Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public void ShouldAddGitIgnore() { var fileSystemMock = new MockFileSystem(); var basePath = Directory.GetCurrentDirectory(); var target = new LoggingInitializer(); var inputs = new StrykerInputs(); inputs.BasePathInput.SuppliedInput = basePath; target.SetupLogOptions(inputs, fileSystemMock); var gitIgnoreFile = fileSystemMock.AllFiles.FirstOrDefault(x => x.EndsWith(Path.Combine("StrykerOutput", ".gitignore"))); gitIgnoreFile.ShouldNotBeNull(); var fileContents = fileSystemMock.GetFile(gitIgnoreFile).Contents; Encoding.Default.GetString(fileContents).ShouldBe("*"); }
public static async Task <int> Main(string[] args) { using (_loggingInitializer = new LoggingInitializer()) { try { InitializeProcess(); _log = LogManager.GetLogger <Program>(); AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; return(await new Program().RunAsync(args).ConfigureAwait(false)); } catch (Exception ex) { _log.Error(ex, "Unhandled exception"); return(1); } } }
public ProgramLoader(IProgram program) { _program = program; _loggingInitializer = new LoggingInitializer(); _log = LogManager.GetLogger <ProgramLoader>(); }
private void AssertLogConfigurationFileIs(string expectedConfigFile, params string[] args) { LoggingInitializer.LoggingConfigurationFileFor(args).Should().Be(expectedConfigFile); }
public static async Task Main(string[] args) { var logging = new LoggingInitializer(); var log = LogManager.GetLogger <Program>(); try { var brokerPath = args.Length > 0 ? args[0] : Path.GetFullPath(@"../.."); Console.WriteLine("Connecting to {0}", brokerPath); var client = ClientFactory.Instance.Create( new ClientOptionsBuilder() .WithDefaultConfiguration(brokerPath) .WithApplicationId("interop.samples.GreetingClient") .Build()); await client.ConnectAsync(); Console.WriteLine("Connected"); var nextCase = true; while (nextCase) { Console.WriteLine( "> Select next example:\n" + "> '1': Unary Call\n" + "> '2': Server Streaming Call\n" + "> '3': Client Streaming Call\n" + "> '4': Duplex Streaming Call\n" + "> '5': Discovery\n" + "> '0': Disconnect"); var c = Console.ReadLine(); switch (c) { case "1": await UnaryRequestExampleAsync(client); break; case "2": await ServerStreamingRequestExampleAsync(client); break; case "3": await ClientStreamingRequestExampleAsync(client); break; case "4": await DuplexStreamingRequestExampleAsync(client); break; case "5": await DiscoveryExampleAsync(client); break; case "0": nextCase = false; break; default: Console.WriteLine("Unknown command: {0}", c); break; } } await client.DisconnectAsync(); Console.WriteLine("Disconnected"); } catch (Exception ex) { Console.WriteLine("Program terminated with exception. See log for details. {0}: {1}", ex.GetType(), ex.Message); log.Error(ex, "Program terminated with exception"); } finally { logging.Dispose(); } Console.WriteLine("> Press any key to exit..."); Console.ReadKey(); }
public TestingInitializer() { _logging = new LoggingInitializer(); LogManager.GetLogger <TestingInitializer>().Info("Initializing tests session"); }