How to stop gracefully the actor system for an akka-http server that must be deployed.

前端 未结 3 1280
轻奢々
轻奢々 2020-12-19 08:03

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 syste

3条回答
  •  渐次进展
    2020-12-19 08:18

    You can add shutdown hook:

    // import scala.concurrent.duration._
    //shutdown Hook
    scala.sys.addShutdownHook {
      logger.info("Terminating...")
      actorSystem.terminate()
      Await.result(actorSystem.whenTerminated, 30 seconds)
      logger.info("Terminated... Bye")
    }
    

提交回复
热议问题