如何正常停止必须部署的akka-http服务器的actor系统。 [英] How to stop gracefully the actor system for an akka-http server that must be deployed.
本文介绍了如何正常停止必须部署的akka-http服务器的actor系统。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚用akka-http创建了我的第一个rest服务器。问题是我不知道如何以可以正常关闭actor系统的方式部署服务器。
I just created my first rest server with akka-http. The problem is that I do not know how to deploy the server in such a way that I could gracefully shutdown the actor system.
例如,我在这里找到了一些东西: https://stackoverflow.com/a/17399574/5388513 ,您可以在其中使用Akka的微内核,但已弃用。我尝试使用sbt-native-package,但是我不知道如何正常关闭actor系统。
For example I found something here: https://stackoverflow.com/a/17399574/5388513 where you could use Akka's microkernel, but it is deprecated. I tried using sbt-native-package, but I do not know how to gracefully shutdown the actor system.
谢谢!
推荐答案
您可以添加关闭挂钩:
// import scala.concurrent.duration._
//shutdown Hook
scala.sys.addShutdownHook {
logger.info("Terminating...")
actorSystem.terminate()
Await.result(actorSystem.whenTerminated, 30 seconds)
logger.info("Terminated... Bye")
}
这篇关于如何正常停止必须部署的akka-http服务器的actor系统。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文