optimize first run (#2516)
* do not accept ui requests until database is ready * add empty database to greatly speed up initial startup * remove middleware
This commit is contained in:
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Add `get_directory_name` and `get_filename_without_extension` functions for path processing
|
||||
- Add `Block Playout Troubleshooting` tool to help investigate block playout history
|
||||
- Add sequential schedule file and scripted schedule file names to playouts table
|
||||
- Add empty (but already up-to-date) sqlite3 database to greatly speed up initial startup for fresh installs
|
||||
|
||||
### Fixed
|
||||
- Fix NVIDIA startup errors on arm64
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
<EmbeddedResource Include="Resources\Templates\_song.sbntxt" />
|
||||
<EmbeddedResource Include="Resources\sequential-schedule-import.schema.json" />
|
||||
<EmbeddedResource Include="Resources\sequential-schedule.schema.json" />
|
||||
<EmbeddedResource Include="Resources\empty.sqlite3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
using Dapper;
|
||||
using System.Reflection;
|
||||
using Dapper;
|
||||
using ErsatzTV.Core;
|
||||
using ErsatzTV.Infrastructure.Data;
|
||||
using Microsoft.Data.Sqlite;
|
||||
@@ -26,11 +27,24 @@ public class DatabaseMigratorService : BackgroundService
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
_logger.LogInformation("Applying database migrations");
|
||||
|
||||
using IServiceScope scope = _serviceScopeFactory.CreateScope();
|
||||
await using TvContext dbContext = scope.ServiceProvider.GetRequiredService<TvContext>();
|
||||
|
||||
// extract empty database to speed up initial startup
|
||||
if (TvContext.IsSqlite && !File.Exists(FileSystemLayout.DatabasePath))
|
||||
{
|
||||
_logger.LogInformation("Extracting empty database to {DatabasePath}", FileSystemLayout.DatabasePath);
|
||||
await using Stream resource = typeof(ResourceExtractorService).GetTypeInfo().Assembly
|
||||
.GetManifestResourceStream("ErsatzTV.Resources.empty.sqlite3");
|
||||
if (resource != null)
|
||||
{
|
||||
await using FileStream fs = File.Create(FileSystemLayout.DatabasePath);
|
||||
await resource.CopyToAsync(fs, stoppingToken);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Applying database migrations");
|
||||
|
||||
if (TvContext.IsSqlite)
|
||||
{
|
||||
int count = await dbContext.Connection.ExecuteScalarAsync<int>(
|
||||
|
||||
Reference in New Issue
Block a user