mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-04 10:58: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;
|
||||||
|
using System.Diagnostics;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
@ -7,17 +8,26 @@ using ProjectLighthouse.Types;
|
||||||
namespace ProjectLighthouse {
|
namespace ProjectLighthouse {
|
||||||
public static class Program {
|
public static class Program {
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
|
Stopwatch startupStopwatch = new();
|
||||||
|
startupStopwatch.Start();
|
||||||
Console.WriteLine("Welcome to Project Lighthouse!");
|
Console.WriteLine("Welcome to Project Lighthouse!");
|
||||||
|
Console.WriteLine("Determining if the database is available...");
|
||||||
bool dbConnected = ServerSettings.DbConnected;
|
bool dbConnected = ServerSettings.DbConnected;
|
||||||
Console.WriteLine(dbConnected ? "Connected to the database." : "Database unavailable. Exiting.");
|
Console.WriteLine(dbConnected ? "Connected to the database." : "Database unavailable. Exiting.");
|
||||||
|
|
||||||
if(dbConnected) {
|
if(dbConnected) {
|
||||||
|
Stopwatch migrationStopwatch = new();
|
||||||
|
migrationStopwatch.Start();
|
||||||
|
|
||||||
Console.WriteLine("Migrating database...");
|
Console.WriteLine("Migrating database...");
|
||||||
new Database().Database.Migrate();
|
new Database().Database.Migrate();
|
||||||
}
|
|
||||||
else {
|
migrationStopwatch.Stop();
|
||||||
Environment.Exit(1);
|
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();
|
CreateHostBuilder(args).Build().Run();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue