mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 16:08:38 +00:00
log startup timings
This commit is contained in:
parent
ccaebbf9fc
commit
d6b141d1f0
1 changed files with 14 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
@ -7,17 +8,26 @@ using ProjectLighthouse.Types;
|
|||
namespace ProjectLighthouse {
|
||||
public static class Program {
|
||||
public static void Main(string[] args) {
|
||||
Stopwatch startupStopwatch = new();
|
||||
startupStopwatch.Start();
|
||||
Console.WriteLine("Welcome to Project Lighthouse!");
|
||||
Console.WriteLine("Determining if the database is available...");
|
||||
bool dbConnected = ServerSettings.DbConnected;
|
||||
Console.WriteLine(dbConnected ? "Connected to the database." : "Database unavailable. Exiting.");
|
||||
|
||||
if(dbConnected) {
|
||||
Stopwatch migrationStopwatch = new();
|
||||
migrationStopwatch.Start();
|
||||
|
||||
Console.WriteLine("Migrating database...");
|
||||
new Database().Database.Migrate();
|
||||
}
|
||||
else {
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
migrationStopwatch.Stop();
|
||||
Console.WriteLine($"Migration took {migrationStopwatch.ElapsedMilliseconds}ms");
|
||||
} else Environment.Exit(1);
|
||||
|
||||
startupStopwatch.Stop();
|
||||
Console.WriteLine($"Ready! Startup took {startupStopwatch.ElapsedMilliseconds}ms. Passing off control to ASP.NET...");
|
||||
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue