public static void Main(string[] args) { StartupConfiguration config = new StartupConfiguration(args); if (config.PrintHelp || config.PrintVersion) { if (config.PrintHelp) { InfoPrinter.PrintHelp(); } else if (config.PrintVersion) { InfoPrinter.PrintVersion(); } return; } UseConfigurationDirectory(config); if (config.CheckDatabaseAvailability) { DataSeed().CheckConnection(); } else if (ShouldUpdate(config)) { if (config.Migrate) { Migrations().Migrate(); } if (config.InitializeCoreData) { DataSeed().SeedInitialize(); } if (config.SeedWithTestData) { DataSeed().SeedAddTestData(config.CategoryTokensToSeed, config.SeedWithCategoryNames); } } else if (config.StartServer) { new ServerStartup().RunServer(config); } else { InfoPrinter.PrintNoArgumentsInfo(); } Migrations.Main Migrations() => new Migrations.Main(config.ConfigRootDir); DataSeed.Main DataSeed() => new DataSeed.Main(config.ConfigRootDir); }
public void RunServer(StartupConfiguration startupConfiguration) { var webHost = CreateWebHostBuilder(startupConfiguration).Build(); IHostingEnvironment env = (IHostingEnvironment)webHost.Services.GetService(typeof(IHostingEnvironment)); IConfiguration conf = (IConfiguration)webHost.Services.GetService(typeof(IConfiguration)); InfoPrinter.PrintVersion(); Startup.SetExceptionsMode(env, conf); webHost.Run(); }
public void RunServer(StartupConfiguration startupConfiguration) { var webHost = CreateHostBuilder(startupConfiguration).Build(); IWebHostEnvironment env = (IWebHostEnvironment)webHost.Services.GetService(typeof(IWebHostEnvironment)); IConfiguration conf = (IConfiguration)webHost.Services.GetService(typeof(IConfiguration)); InfoPrinter.PrintVersion(); Startup.SetExceptionsMode(env, conf); new InfrastructurePreparer((IConfigurationRoot)conf).DoAll(); webHost.Run(); }
/// <summary> /// Entry point of CLI /// </summary> public static void Main(string[] args) { StartupConfiguration config = new StartupConfiguration(args); if (config.NoLogo) { InfoPrinter.PrintVersion(); } else { InfoPrinter.PrintLogoAndVersion(); } if (config.PrintHelp || config.PrintVersion) { if (config.PrintHelp) { InfoPrinter.PrintHelp(); } else if (config.PrintVersion) { InfoPrinter.PrintVersion(); } return; } if (config.CheckNoArguments()) { InfoPrinter.PrintNoArgumentsInfo(); return; } config.InitConfigurationDirectory(); InfoPrinter.PrintServerInfo(config.ConfigRootDir); if (config.CheckDatabaseAvailability) { if (!DataSeed().PrintDbConnectionAvailability()) { Environment.Exit(1); } } else if (config.UsersPasswords.Count > 0) { DataSeed().SetUsersPasswords(config.UsersPasswords); } else if (ShouldUpdate(config)) { if (config.Migrate) { Migrations().Migrate(); } if (config.InitializeCoreData) { DataSeed().SeedInitialize(); } if (config.SeedWithTestData) { DataSeed().SeedAddTestData(config.CategoryTokensToSeed, config.SeedWithCategoryNames); } } else if (config.StartServer) { new ServerRun().RunServer(config); } else { InfoPrinter.PrintNoArgumentsInfo(); } Migrations.Main Migrations() => new Migrations.Main(config.ConfigRootDir); DataSeed.Main DataSeed() => new DataSeed.Main(config.ConfigRootDir); }