Split API into its own project

This commit is contained in:
jvyden 2022-05-14 16:46:28 -04:00
parent 2aa803f69f
commit 47271d1798
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
16 changed files with 336 additions and 162 deletions

View file

@ -2,6 +2,5 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/ProjectLighthouse/Fomantic" vcs="Git" />
</component> </component>
</project> </project>

View file

@ -0,0 +1,35 @@
using LBPUnion.ProjectLighthouse.Logging.Loggers.AspNet;
using LBPUnion.ProjectLighthouse.Types;
using LBPUnion.ProjectLighthouse.Types.Settings;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace LBPUnion.ProjectLighthouse.API;
public static class Program
{
public static void Main(string[] args)
{
StartupTasks.Run(args, ServerType.Api);
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args)
=> Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults
(
webBuilder =>
{
webBuilder.UseStartup<ApiStartup>();
webBuilder.UseUrls(ServerConfiguration.Instance.ListenUrl);
}
)
.ConfigureLogging
(
logging =>
{
logging.ClearProviders();
logging.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, AspNetToLighthouseLoggerProvider>());
}
);
}

View file

@ -0,0 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>LBPUnion.ProjectLighthouse.API</AssemblyName>
<RootNamespace>LBPUnion.ProjectLighthouse.API</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ProjectLighthouse\ProjectLighthouse.csproj"/>
</ItemGroup>
<ItemGroup>
<None Remove="gitVersion.txt"/>
<EmbeddedResource Include="gitVersion.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<None Remove="gitBranch.txt"/>
<EmbeddedResource Include="gitBranch.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<None Remove="gitRemotes.txt"/>
<EmbeddedResource Include="gitRemotes.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<None Remove="gitUnpushed.txt"/>
<EmbeddedResource Include="gitUnpushed.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="git describe --long --always --dirty --exclude=\* --abbrev=8 &gt; &quot;$(ProjectDir)/gitVersion.txt&quot;"/>
<Exec Command="git branch --show-current &gt; &quot;$(ProjectDir)/gitBranch.txt&quot;"/>
<Exec Command="git remote -v &gt; &quot;$(ProjectDir)/gitRemotes.txt&quot;"/>
<Exec Command="git log --branches --not --remotes --oneline &gt; &quot;$(ProjectDir)/gitUnpushed.txt&quot;"/>
</Target>
</Project>

View file

@ -0,0 +1,75 @@
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Startup.Middlewares;
using Microsoft.OpenApi.Models;
namespace LBPUnion.ProjectLighthouse.API;
public class ApiStartup
{
public ApiStartup(IConfiguration configuration)
{
this.Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddMvc
(
options =>
{
options.OutputFormatters.Add(new JsonOutputFormatter());
}
);
services.AddDbContext<Database>();
services.AddSwaggerGen
(
c =>
{
// Give swagger the name and version of our project
c.SwaggerDoc
(
"v1",
new OpenApiInfo
{
Title = "Project Lighthouse API",
Version = "v1",
}
);
// Filter out endpoints not in /api/v1
c.DocumentFilter<SwaggerFilter>();
// Add XMLDoc to swagger
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "LBPUnion.ProjectLighthouse.API.xml"));
}
);
}
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
#if DEBUG
app.UseDeveloperExceptionPage();
#endif
app.UseSwagger();
app.UseSwaggerUI
(
c =>
{
c.SwaggerEndpoint("v1/swagger.json", "Project Lighthouse API");
}
);
app.UseMiddleware<RequestLogMiddleware>();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}

View file

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View file

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View file

@ -15,7 +15,7 @@ public class LighthouseWebTest : IDisposable
public readonly string BaseAddress; public readonly string BaseAddress;
public readonly IWebDriver Driver; public readonly IWebDriver Driver;
public readonly IWebHost WebHost = new WebHostBuilder().UseKestrel().UseStartup<TestStartup>().UseWebRoot("StaticFiles").Build(); public readonly IWebHost WebHost = new WebHostBuilder().UseKestrel().UseStartup<TestGameApiStartup>().UseWebRoot("StaticFiles").Build();
public LighthouseWebTest() public LighthouseWebTest()
{ {

View file

@ -22,7 +22,7 @@ public class LighthouseServerTest
public LighthouseServerTest() public LighthouseServerTest()
{ {
this.Server = new TestServer(new WebHostBuilder().UseStartup<TestStartup>()); this.Server = new TestServer(new WebHostBuilder().UseStartup<TestGameApiStartup>());
this.Client = this.Server.CreateClient(); this.Client = this.Server.CreateClient();
} }
public async Task<HttpResponseMessage> AuthenticateResponse(int number = -1, bool createUser = true) public async Task<HttpResponseMessage> AuthenticateResponse(int number = -1, bool createUser = true)

View file

@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectLighthouse.Tests.Gam
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectLighthouse.Tests.WebsiteTests", "ProjectLighthouse.Tests.WebsiteTests\ProjectLighthouse.Tests.WebsiteTests.csproj", "{CF65EB5B-5364-4D2A-8639-F147A67F08E7}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectLighthouse.Tests.WebsiteTests", "ProjectLighthouse.Tests.WebsiteTests\ProjectLighthouse.Tests.WebsiteTests.csproj", "{CF65EB5B-5364-4D2A-8639-F147A67F08E7}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectLighthouse.API", "ProjectLighthouse.API\ProjectLighthouse.API.csproj", "{5593825E-F5C9-467F-9125-3E3249CFEEAB}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -29,6 +31,10 @@ Global
{CF65EB5B-5364-4D2A-8639-F147A67F08E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CF65EB5B-5364-4D2A-8639-F147A67F08E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF65EB5B-5364-4D2A-8639-F147A67F08E7}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF65EB5B-5364-4D2A-8639-F147A67F08E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF65EB5B-5364-4D2A-8639-F147A67F08E7}.Release|Any CPU.ActiveCfg = Release|Any CPU {CF65EB5B-5364-4D2A-8639-F147A67F08E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5593825E-F5C9-467F-9125-3E3249CFEEAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5593825E-F5C9-467F-9125-3E3249CFEEAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5593825E-F5C9-467F-9125-3E3249CFEEAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5593825E-F5C9-467F-9125-3E3249CFEEAB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{AFC74569-B289-4ACC-B21C-313A3A62C017} = {D360C08E-EA47-43AC-A566-FDF413442980} {AFC74569-B289-4ACC-B21C-313A3A62C017} = {D360C08E-EA47-43AC-A566-FDF413442980}

View file

@ -1,13 +1,9 @@
#nullable enable #nullable enable
using System;
using System.Diagnostics;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Logging.Loggers;
using LBPUnion.ProjectLighthouse.Logging.Loggers.AspNet; using LBPUnion.ProjectLighthouse.Logging.Loggers.AspNet;
using LBPUnion.ProjectLighthouse.Startup;
using LBPUnion.ProjectLighthouse.Types;
using LBPUnion.ProjectLighthouse.Types.Settings; using LBPUnion.ProjectLighthouse.Types.Settings;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
@ -19,88 +15,18 @@ public static class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
// Log startup time StartupTasks.Run(args, ServerType.GameApi);
Stopwatch stopwatch = new();
stopwatch.Start();
// Setup logging
Logger.AddLogger(new ConsoleLogger());
Logger.AddLogger(new LighthouseFileLogger());
Logger.LogInfo("Welcome to Project Lighthouse!", LogArea.Startup);
Logger.LogInfo($"You are running version {VersionHelper.FullVersion}", LogArea.Startup);
// Referencing ServerSettings.Instance here loads the config, see ServerSettings.cs for more information
Logger.LogSuccess("Loaded config file version " + ServerConfiguration.Instance.ConfigVersion, LogArea.Startup);
Logger.LogInfo("Determining if the database is available...", LogArea.Startup);
bool dbConnected = ServerStatics.DbConnected;
if (!dbConnected)
{
Logger.LogError("Database unavailable! Exiting.", LogArea.Startup);
}
else
{
Logger.LogSuccess("Connected to the database.", LogArea.Startup);
}
if (!dbConnected) Environment.Exit(1);
using Database database = new();
Logger.LogInfo("Migrating database...", LogArea.Database);
MigrateDatabase(database);
if (ServerConfiguration.Instance.InfluxDB.InfluxEnabled)
{
Logger.LogInfo("Influx logging is enabled. Starting influx logging...", LogArea.Startup);
InfluxHelper.StartLogging().Wait();
if (ServerConfiguration.Instance.InfluxDB.LoggingEnabled) Logger.AddLogger(new InfluxLogger());
}
Logger.LogDebug
(
"This is a debug build, so performance may suffer! " +
"If you are running Lighthouse in a production environment, " +
"it is highly recommended to run a release build. ",
LogArea.Startup
);
Logger.LogDebug("You can do so by running any dotnet command with the flag: \"-c Release\". ", LogArea.Startup);
if (args.Length != 0)
{
MaintenanceHelper.RunCommand(args).Wait();
return;
}
if (ServerConfiguration.Instance.WebsiteConfiguration.ConvertAssetsOnStartup) FileHelper.ConvertAllTexturesToPng();
Logger.LogInfo("Starting room cleanup thread...", LogArea.Startup);
RoomHelper.StartCleanupThread();
stopwatch.Stop();
Logger.LogSuccess($"Ready! Startup took {stopwatch.ElapsedMilliseconds}ms. Passing off control to ASP.NET...", LogArea.Startup);
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
} }
public static void MigrateDatabase(Database database)
{
Stopwatch stopwatch = new();
stopwatch.Start();
database.Database.MigrateAsync().Wait();
stopwatch.Stop();
Logger.LogSuccess($"Migration took {stopwatch.ElapsedMilliseconds}ms.", LogArea.Database);
}
public static IHostBuilder CreateHostBuilder(string[] args) public static IHostBuilder CreateHostBuilder(string[] args)
=> Host.CreateDefaultBuilder(args) => Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults .ConfigureWebHostDefaults
( (
webBuilder => webBuilder =>
{ {
webBuilder.UseStartup<Startup.Startup>(); webBuilder.UseStartup<GameApiStartup>();
webBuilder.UseWebRoot("StaticFiles"); webBuilder.UseWebRoot("StaticFiles");
webBuilder.UseUrls(ServerConfiguration.Instance.ListenUrl); webBuilder.UseUrls(ServerConfiguration.Instance.ListenUrl);
} }

View file

@ -6,11 +6,6 @@
<RootNamespace>LBPUnion.ProjectLighthouse</RootNamespace> <RootNamespace>LBPUnion.ProjectLighthouse</RootNamespace>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3"/> <PackageReference Include="BCrypt.Net-Next" Version="4.0.3"/>
<PackageReference Include="DDSReader" Version="1.0.8-pre"/> <PackageReference Include="DDSReader" Version="1.0.8-pre"/>

View file

@ -1,30 +1,27 @@
using System; using System;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Startup.Middlewares;
using LBPUnion.ProjectLighthouse.Types; using LBPUnion.ProjectLighthouse.Types;
using LBPUnion.ProjectLighthouse.Types.Settings; using LBPUnion.ProjectLighthouse.Types.Settings;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using Microsoft.OpenApi.Models;
#if RELEASE #if RELEASE
using Microsoft.Extensions.Hosting.Internal; using Microsoft.Extensions.Hosting.Internal;
#endif #endif
namespace LBPUnion.ProjectLighthouse.Startup; namespace LBPUnion.ProjectLighthouse.Startup;
public class Startup public class GameApiStartup
{ {
public Startup(IConfiguration configuration) public GameApiStartup(IConfiguration configuration)
{ {
this.Configuration = configuration; this.Configuration = configuration;
} }
@ -60,30 +57,6 @@ public class Startup
} }
); );
services.AddSwaggerGen
(
c =>
{
// Give swagger the name and version of our project
c.SwaggerDoc
(
"v1",
new OpenApiInfo
{
Title = "Project Lighthouse API",
Version = "v1",
}
);
// Filter out endpoints not in /api/v1
c.DocumentFilter<SwaggerFilter>();
// Add XMLDoc to swagger
string xmlDocs = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlDocs));
}
);
#if DEBUG #if DEBUG
services.AddSingleton<IHostLifetime, DebugWarmupLifetime>(); services.AddSingleton<IHostLifetime, DebugWarmupLifetime>();
#else #else
@ -113,50 +86,7 @@ public class Startup
app.UseForwardedHeaders(); app.UseForwardedHeaders();
app.UseSwagger(); app.UseMiddleware<RequestLogMiddleware>();
app.UseSwaggerUI
(
c =>
{
c.SwaggerEndpoint("v1/swagger.json", "Project Lighthouse API");
}
);
// Logs every request and the response to it
// Example: "200, 13ms: GET /LITTLEBIGPLANETPS3_XML/news"
// Example: "404, 127ms: GET /asdasd?query=osucookiezi727ppbluezenithtopplayhdhr"
app.Use
(
async (context, next) =>
{
Stopwatch requestStopwatch = new();
requestStopwatch.Start();
context.Request.EnableBuffering(); // Allows us to reset the position of Request.Body for later logging
// Log all headers.
// foreach (KeyValuePair<string, StringValues> header in context.Request.Headers) Logger.Log($"{header.Key}: {header.Value}");
await next(context); // Handle the request so we can get the status code from it
requestStopwatch.Stop();
Logger.LogInfo
(
$"{context.Response.StatusCode}, {requestStopwatch.ElapsedMilliseconds}ms: {context.Request.Method} {context.Request.Path}{context.Request.QueryString}",
LogArea.HTTP
);
#if DEBUG
// Log post body
if (context.Request.Method == "POST")
{
context.Request.Body.Position = 0;
Logger.LogDebug(await new StreamReader(context.Request.Body).ReadToEndAsync(), LogArea.HTTP);
}
#endif
}
);
// Digest check // Digest check
app.Use app.Use

View file

@ -0,0 +1,50 @@
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Logging;
using Microsoft.AspNetCore.Http;
namespace LBPUnion.ProjectLighthouse.Startup.Middlewares;
public class RequestLogMiddleware
{
private readonly RequestDelegate next;
public RequestLogMiddleware(RequestDelegate next)
{
this.next = next;
}
// Logs every request and the response to it
// Example: "200, 13ms: GET /LITTLEBIGPLANETPS3_XML/news"
// Example: "404, 127ms: GET /asdasd?query=osucookiezi727ppbluezenithtopplayhdhr"
public async Task InvokeAsync(HttpContext context)
{
Stopwatch requestStopwatch = new();
requestStopwatch.Start();
context.Request.EnableBuffering(); // Allows us to reset the position of Request.Body for later logging
// Log all headers.
// foreach (KeyValuePair<string, StringValues> header in context.Request.Headers) Logger.Log($"{header.Key}: {header.Value}");
await next(context); // Handle the request so we can get the status code from it
requestStopwatch.Stop();
Logger.LogInfo
(
$"{context.Response.StatusCode}, {requestStopwatch.ElapsedMilliseconds}ms: {context.Request.Method} {context.Request.Path}{context.Request.QueryString}",
LogArea.HTTP
);
#if DEBUG
// Log post body
if (context.Request.Method == "POST")
{
context.Request.Body.Position = 0;
Logger.LogDebug(await new StreamReader(context.Request.Body).ReadToEndAsync(), LogArea.HTTP);
}
#endif
}
}

View file

@ -5,9 +5,9 @@ using Microsoft.Extensions.Configuration;
namespace LBPUnion.ProjectLighthouse.Startup; namespace LBPUnion.ProjectLighthouse.Startup;
public class TestStartup : Startup public class TestGameApiStartup : GameApiStartup
{ {
public TestStartup(IConfiguration configuration) : base(configuration) public TestGameApiStartup(IConfiguration configuration) : base(configuration)
{} {}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env) public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)

View file

@ -0,0 +1,88 @@
using System;
using System.Diagnostics;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Logging.Loggers;
using LBPUnion.ProjectLighthouse.Types;
using LBPUnion.ProjectLighthouse.Types.Settings;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse;
public static class StartupTasks
{
public static void Run(string[] args, ServerType serverType)
{
// Log startup time
Stopwatch stopwatch = new();
stopwatch.Start();
// Setup logging
Logger.AddLogger(new ConsoleLogger());
Logger.AddLogger(new LighthouseFileLogger());
Logger.LogInfo($"Welcome to the Project Lighthouse {serverType.ToString()}!", LogArea.Startup);
Logger.LogInfo($"You are running version {VersionHelper.FullVersion}", LogArea.Startup);
// Referencing ServerSettings.Instance here loads the config, see ServerSettings.cs for more information
Logger.LogSuccess("Loaded config file version " + ServerConfiguration.Instance.ConfigVersion, LogArea.Startup);
Logger.LogInfo("Determining if the database is available...", LogArea.Startup);
bool dbConnected = ServerStatics.DbConnected;
if (!dbConnected)
{
Logger.LogError("Database unavailable! Exiting.", LogArea.Startup);
}
else
{
Logger.LogSuccess("Connected to the database.", LogArea.Startup);
}
if (!dbConnected) Environment.Exit(1);
using Database database = new();
Logger.LogInfo("Migrating database...", LogArea.Database);
migrateDatabase(database);
if (ServerConfiguration.Instance.InfluxDB.InfluxEnabled)
{
Logger.LogInfo("Influx logging is enabled. Starting influx logging...", LogArea.Startup);
InfluxHelper.StartLogging().Wait();
if (ServerConfiguration.Instance.InfluxDB.LoggingEnabled) Logger.AddLogger(new InfluxLogger());
}
Logger.LogDebug
(
"This is a debug build, so performance may suffer! " +
"If you are running Lighthouse in a production environment, " +
"it is highly recommended to run a release build. ",
LogArea.Startup
);
Logger.LogDebug("You can do so by running any dotnet command with the flag: \"-c Release\". ", LogArea.Startup);
if (args.Length != 0)
{
MaintenanceHelper.RunCommand(args).Wait();
return;
}
if (ServerConfiguration.Instance.WebsiteConfiguration.ConvertAssetsOnStartup) FileHelper.ConvertAllTexturesToPng();
Logger.LogInfo("Starting room cleanup thread...", LogArea.Startup);
RoomHelper.StartCleanupThread();
stopwatch.Stop();
Logger.LogSuccess($"Ready! Startup took {stopwatch.ElapsedMilliseconds}ms. Passing off control to ASP.NET...", LogArea.Startup);
}
private static void migrateDatabase(Database database)
{
Stopwatch stopwatch = new();
stopwatch.Start();
database.Database.MigrateAsync().Wait();
stopwatch.Stop();
Logger.LogSuccess($"Migration took {stopwatch.ElapsedMilliseconds}ms.", LogArea.Database);
}
}

View file

@ -0,0 +1,8 @@
namespace LBPUnion.ProjectLighthouse.Types;
public enum ServerType
{
GameApi = 0,
Website = 1,
Api = 2,
}