log startup timings

This commit is contained in:
jvyden 2021-10-18 22:42:16 -04:00
commit d6b141d1f0
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -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();
}