Browse Source

Merge pull request #3577 from abpframework/maliming/console-patch

Use IHostApplicationLifetime to manually terminate the console application.
pull/3581/head
Halil İbrahim Kalkan 7 years ago
committed by GitHub
parent
commit
d10dbfb853
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/DbMigratorHostedService.cs

9
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/DbMigratorHostedService.cs

@ -10,6 +10,13 @@ namespace MyCompanyName.MyProjectName.DbMigrator
{
public class DbMigratorHostedService : IHostedService
{
private readonly IHostApplicationLifetime _hostApplicationLifetime;
public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime)
{
_hostApplicationLifetime = hostApplicationLifetime;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
using (var application = AbpApplicationFactory.Create<MyProjectNameDbMigratorModule>(options =>
@ -26,6 +33,8 @@ namespace MyCompanyName.MyProjectName.DbMigrator
.MigrateAsync();
application.Shutdown();
_hostApplicationLifetime.StopApplication();
}
}

Loading…
Cancel
Save