private static Command CreateRunCommand(string[] args) { var command = new Command("run", "run the application") { CommonArguments.Path_Required, }; // TODO: We'll need to support a --build-args command.AddOption(new Option("--no-build") { Description = "Do not build project files before running.", Required = false }); command.AddOption(new Option("--port") { Description = "The port to run control plane on.", Argument = new Argument <int>("port"), Required = false }); command.AddOption(new Option("--logs") { Description = "Write structured application logs to the specified log providers. Supported providers are console, elastic (Elasticsearch), ai (ApplicationInsights), seq.", Argument = new Argument <string>("logs"), Required = false }); command.AddOption(new Option("--dtrace") { Description = "Write distributed traces to the specified providers. Supported providers are zipkin.", Argument = new Argument <string>("logs"), Required = false }); command.AddOption(new Option("--debug") { Description = "Wait for debugger attach in all services.", Required = false }); command.Handler = CommandHandler.Create <IConsole, FileInfo>(async(console, path) => { // Workaround for https://github.com/dotnet/command-line-api/issues/723#issuecomment-593062654 if (path is null) { throw new CommandException("No project or solution file was found."); } var application = ConfigFactory.FromFile(path); var serviceCount = application.Services.Count; InitializeThreadPoolSettings(serviceCount); using var host = new TyeHost(application.ToHostingApplication(), args); await host.RunAsync(); }); return(command); }
private static Command CreateRunCommand() { var command = new Command("run", "run the application") { CommonArguments.Path_Required, new Option("--no-build") { Description = "Do not build project files before running.", Required = false }, new Option("--port") { Description = "The port to run control plane on.", Argument = new Argument <int?>("port"), Required = false }, new Option("--logs") { Description = "Write structured application logs to the specified log provider. Supported providers are 'console', 'elastic' (Elasticsearch), 'ai' (ApplicationInsights), 'seq'.", Argument = new Argument <string>("logs"), Required = false }, new Option("--dtrace") { Description = "Write distributed traces to the specified tracing provider. Supported providers are 'zipkin'.", Argument = new Argument <string>("trace"), Required = false, }, new Option("--metrics") { Description = "Write metrics to the specified metrics provider.", Argument = new Argument <string>("metrics"), Required = false }, new Option("--debug") { Argument = new Argument <string[]>("service") { Arity = ArgumentArity.ZeroOrMore, }, Description = "Wait for debugger attach to specific service. Specify \"*\" to wait for all services.", Required = false }, new Option("--docker") { Description = "Run projects as docker containers.", Required = false }, new Option("--dashboard") { Description = "Launch dashboard on run.", Required = false }, new Option("--watch") { Description = "Watches for code changes for all dotnet projects.", Required = false }, StandardOptions.Framework, StandardOptions.Tags, StandardOptions.Verbosity, }; command.Handler = CommandHandler.Create <RunCommandArguments>(async args => { // Workaround for https://github.com/dotnet/command-line-api/issues/723#issuecomment-593062654 if (args.Path is null) { throw new CommandException("No project or solution file was found."); } var output = new OutputContext(args.Console, args.Verbosity); output.WriteInfoLine("Loading Application Details..."); var filter = ApplicationFactoryFilter.GetApplicationFactoryFilter(args.Tags); var application = await ApplicationFactory.CreateAsync(output, args.Path, args.Framework, filter); if (application.Services.Count == 0) { throw new CommandException($"No services found in \"{application.Source.Name}\""); } var options = new HostOptions() { Dashboard = args.Dashboard, Docker = args.Docker, NoBuild = args.NoBuild, Port = args.Port, // parsed later by the diagnostics code DistributedTraceProvider = args.Dtrace, LoggingProvider = args.Logs, MetricsProvider = args.Metrics, LogVerbosity = args.Verbosity, Watch = args.Watch }; options.Debug.AddRange(args.Debug); await application.ProcessExtensionsAsync(options, output, ExtensionContext.OperationKind.LocalRun); InitializeThreadPoolSettings(application.Services.Count); output.WriteInfoLine("Launching Tye Host..."); output.WriteInfoLine(string.Empty); await using var host = new TyeHost(application.ToHostingApplication(), options); await host.RunAsync(); }); return(command); }
private static Command CreateRunCommand(string[] args) { var command = new Command("run", "run the application") { CommonArguments.Path_Required, }; // TODO: We'll need to support a --build-args command.AddOption(new Option("--no-build") { Description = "Do not build project files before running.", Required = false }); command.AddOption(new Option("--port") { Description = "The port to run control plane on.", Argument = new Argument <int>("port"), Required = false }); command.AddOption(new Option("--logs") { Description = "Write structured application logs to the specified log providers. Supported providers are console, elastic (Elasticsearch), ai (ApplicationInsights), seq.", Argument = new Argument <string>("logs"), Required = false }); command.AddOption(new Option("--dtrace") { Description = "Write distributed traces to the specified providers. Supported providers are zipkin.", Argument = new Argument <string>("logs"), Required = false }); command.AddOption(new Option("--debug") { Argument = new Argument <string[]>("service"), Description = "Wait for debugger attach to specific service. Specify \"*\" to wait for all services.", Required = false }); command.AddOption(new Option("--docker") { Description = "Run projects as docker containers.", Required = false }); command.Handler = CommandHandler.Create <IConsole, FileInfo, string[]>(async(console, path, debug) => { // Workaround for https://github.com/dotnet/command-line-api/issues/723#issuecomment-593062654 if (path is null) { throw new CommandException("No project or solution file was found."); } var output = new OutputContext(console, Verbosity.Quiet); var application = await ApplicationFactory.CreateAsync(output, path); await application.ProcessExtensionsAsync(ExtensionContext.OperationKind.LocalRun); InitializeThreadPoolSettings(application.Services.Count); if (application.Services.Count == 0) { throw new CommandException($"No services found in \"{application.Source.Name}\""); } await using var host = new TyeHost(application.ToHostingApplication(), args, debug); await host.RunAsync(); }); return(command); }