Asp.net core asp.NET核心应用程序中的AKKA.NET actor系统未正确关闭
我正在asp.NET核心应用程序(框架net46)中运行AKKA.NET actor系统。我通过运行“dotnet run”从命令提示符运行web应用程序,当我尝试使用ctrl-c退出它时,我得到以下输出,提示符挂起:Asp.net core asp.NET核心应用程序中的AKKA.NET actor系统未正确关闭,asp.net-core,akka.net,Asp.net Core,Akka.net,我正在asp.NET核心应用程序(框架net46)中运行AKKA.NET actor系统。我通过运行“dotnet run”从命令提示符运行web应用程序,当我尝试使用ctrl-c退出它时,我得到以下输出,提示符挂起: c:\D3\>19:05:33.7024266 ENV=d0 Sdm.Web DEBUG Akka.Actor.Internal.ActorSystemImpl Disposing system 19:05:33.7
c:\D3\>19:05:33.7024266 ENV=d0 Sdm.Web DEBUG Akka.Actor.Internal.ActorSystemImpl Disposing system
19:05:33.7084292 ENV=d0 Sdm.Web DEBUG Akka.Actor.Internal.ActorSystemImpl System shutdown initiated
[DEBUG][12/09/16 19:05:33][Thread 0023][EventStream] subscribing [akka://all-systems/] to channel Akka.Event.Debug
19:05:33.7134423 ENV=d0 Sdm.Web DEBUG Akka.Actor.GuardianActor Stopping
[DEBUG][12/09/16 19:05:33][Thread 0023][EventStream] subscribing [akka://all-systems/] to channel Akka.Event.Info
[DEBUG][12/09/16 19:05:33][Thread 0023][EventStream] subscribing [akka://all-systems/] to channel Akka.Event.Warning
[DEBUG][12/09/16 19:05:33][Thread 0023][EventStream] subscribing [akka://all-systems/] to channel Akka.Event.Error
如果我按下另一个ctrl-c键,它就会退出。但这似乎不对
我使用依赖项注入容器来管理actor系统的生命周期(单例作用域),因此我假设容器实际上是在应用程序关闭时处理对象
有人能提出可能的错误吗?如果你想正常关机,你需要直接停止Akka.NET演员。为此,请使用ASP.NET Core通过接口提供的应用程序关闭事件:
CancellationToken ApplicationStopping { get; }
CancellationToken ApplicationStopped { get; }
可以在Startup.cs期间通过Configure
方法获取iaapplicationlifetime
的实例:
protected void DisposeResources()
{
//Cleanup stuff when the app is shutting down
}
public void Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime)
{
//register the application shutdown handler
applicationLifetime.ApplicationStopping.Register(DisposeResources);
}
有关更多详细信息,请参阅文章
还有一个问题:如果您想要正常关机,您需要直接停止Akka.NET Actors。为此,请使用ASP.NET Core通过接口提供的应用程序关闭事件:
CancellationToken ApplicationStopping { get; }
CancellationToken ApplicationStopped { get; }
可以在Startup.cs期间通过Configure
方法获取iaapplicationlifetime
的实例:
protected void DisposeResources()
{
//Cleanup stuff when the app is shutting down
}
public void Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime)
{
//register the application shutdown handler
applicationLifetime.ApplicationStopping.Register(DisposeResources);
}
有关更多详细信息,请参阅文章
因此,这个问题: