stop application if worker fails
This commit is contained in:
parent
9bdca4e202
commit
30bd16447f
1 changed files with 12 additions and 3 deletions
|
@ -13,19 +13,28 @@ namespace BirdsiteLive.Services
|
|||
{
|
||||
private readonly IDatabaseInitializer _databaseInitializer;
|
||||
private readonly IStatusPublicationPipeline _statusPublicationPipeline;
|
||||
private readonly IHostApplicationLifetime _applicationLifetime;
|
||||
|
||||
#region Ctor
|
||||
public FederationService(IDatabaseInitializer databaseInitializer, IStatusPublicationPipeline statusPublicationPipeline)
|
||||
public FederationService(IDatabaseInitializer databaseInitializer, IStatusPublicationPipeline statusPublicationPipeline, IHostApplicationLifetime applicationLifetime)
|
||||
{
|
||||
_databaseInitializer = databaseInitializer;
|
||||
_statusPublicationPipeline = statusPublicationPipeline;
|
||||
_applicationLifetime = applicationLifetime;
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await _databaseInitializer.InitAndMigrateDbAsync();
|
||||
await _statusPublicationPipeline.ExecuteAsync(stoppingToken);
|
||||
try
|
||||
{
|
||||
await _databaseInitializer.InitAndMigrateDbAsync();
|
||||
await _statusPublicationPipeline.ExecuteAsync(stoppingToken);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_applicationLifetime.StopApplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue