예제 #1
0
        static async Task <int> Main(string[] args)
        {
            // https://github.com/Azure/azure-storage-net-data-movement#increase-net-http-connections-limit
            System.Net.ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount * 16;
            System.Net.ServicePointManager.Expect100Continue      = false;

            TransferManager.Configurations.ParallelOperations    = System.Net.ServicePointManager.DefaultConnectionLimit;
            TransferManager.Configurations.MaxListingConcurrency = 20;
            TransferManager.Configurations.BlockSize             = 20971520;

            Log.Logger = StandardLogging.CreateStandardSerilogConfiguration().CreateLogger();

            int result;

            try
            {
                result = await Runner.ExecuteAsync(args);
            }
            catch (Exception t)
            {
                Utilities.HandleError(t);
                result = 1;
            }
            finally
            {
                Log.CloseAndFlush();
            }

            return(result);
        }
예제 #2
0
        public static async Task <int> ExecuteAsync(string[] args)
        {
            RootCommand?rootCommand = null;

            try
            {
                rootCommand = ConfigureCommands();
            }
            catch (Exception t)
            {
                throw new RecoverableException("Failed to configure commands.", t);
            }


            var initialParse       = rootCommand.Parse(args);
            var isIntegrationTests = initialParse.CommandResult.Command.Name == IntegrationTestsCommand.Name;

            var parser = new CommandLineBuilder(rootCommand)
                         .UseDefaults()
                         .UseExceptionHandler((t, c) =>
            {
                Utilities.HandleError(t);
                c.ExitCode = 1;
            })
                         .UseHost(Host.CreateDefaultBuilder, host =>
            {
                host
                .ConfigureHostConfiguration(ConfigureHostConfiguration)
                .UseSerilog(
                    (context, loggerConfiguration) =>
                {
                    StandardLogging.CreateStandardSerilogConfiguration(loggerConfiguration);
                })
                .ConfigureServices((c, s) => ConfigureServices(c, s, isIntegrationTests));
            })
                         .Build();

            return(await parser.InvokeAsync(args));
        }