AKKA.NET actor system not shut down correctly in asp.net core application -
i'm running akka.net actor system inside asp.net core application (framework net46). run web-application command prompt running 'dotnet run' , when try exit using ctrl-c following output , prompt hangs there:
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/] 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/] channel akka.event.info [debug][12/09/16 19:05:33][thread 0023][eventstream] subscribing [akka://all-systems/] channel akka.event.warning [debug][12/09/16 19:05:33][thread 0023][eventstream] subscribing [akka://all-systems/] channel akka.event.error
if hit ctrl-c exits. doesn't seem right.
i'm using dependency injection container manage life time of actor system (singleton-scope) assume container trying dispose object @ application shutdown.
can suggest might wrong?
you need directly stopping akka.net actors if want graceful shutdown. use application shutdown events provided asp.net core via iapplicationlifetime interface:
cancellationtoken applicationstopping { get; } cancellationtoken applicationstopped { get; }
obtaining instance of iapplicationlifetime
can done during startup.cs in configure
method:
protected void disposeresources() { //cleanup stuff when app shutting down } public void configure(iapplicationbuilder app, iapplicationlifetime applicationlifetime) { //register application shutdown handler applicationlifetime.applicationstopping.register(disposeresources); }
for more details see article asp.net core application shutdown events , question kestrel shutdown function in startup.cs in asp.net core:
Comments
Post a Comment