Files
server/util/Server/Program.cs

50 lines
1.3 KiB
C#
Raw Normal View History

// FIXME: Update this file to be null safe and then delete the line below
#nullable disable
namespace Bit.Server;
2022-08-29 16:06:55 -04:00
public class Program
{
2022-08-29 16:06:55 -04:00
public static void Main(string[] args)
{
var builder = CreateWebHostBuilder(args);
var host = builder.Build();
host.Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
2022-08-29 16:06:55 -04:00
var config = new ConfigurationBuilder()
.AddCommandLine(args)
.Build();
2022-08-29 16:06:55 -04:00
var builder = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
.UseStartup<Startup>()
.ConfigureLogging((hostingContext, logging) =>
{
2022-08-29 16:06:55 -04:00
logging.AddConsole().AddDebug();
})
.ConfigureKestrel((context, options) => { });
2022-08-29 16:06:55 -04:00
var contentRoot = config.GetValue<string>("contentRoot");
if (!string.IsNullOrWhiteSpace(contentRoot))
{
builder.UseContentRoot(contentRoot);
}
else
{
builder.UseContentRoot(Directory.GetCurrentDirectory());
}
2022-08-29 16:06:55 -04:00
var webRoot = config.GetValue<string>("webRoot");
if (string.IsNullOrWhiteSpace(webRoot))
{
builder.UseWebRoot(webRoot);
}
2022-08-29 16:06:55 -04:00
return builder;
}
}