-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to keep running an akka-http server in production #1460
Comments
Will work on it if no one else wants to pick this up in the next few days. |
FYI, since I'm the grumpy developer who lodged the complaint about the documentation :-/, what worked perfectly for me was one of these: With Override override protected def waitForShutdownSignal(system: ActorSystem)
(implicit ec: ExecutionContext): Future[Done] = {
Promise[Done].future
} Rolling your own Something like this: val f = for { bindingFuture <- Http().bindAndHandle(routes, host, port)
waitOnFuture <- Promise[Done].future }
yield waitOnFuture
sys.addShutdownHook {
// cleanup logic
}
Await.ready(f, Duration.Inf) |
This should talk about coordinated shutdown https://doc.akka.io/docs/akka/current/scala/actors.html#coordinated-shutdown Though we're missing that bit still in HTTP actually: #1210 So I propose to solve #1210 and then document things :) |
I think just adding the documentation for creating a future that never completes would be very helpful in the short term. Having a future that never completes feels like I'm doing something wrong. Also, I think the current default shutdown strategies have issues when using sbt-revolver. E.g. they start up and instantly shut down. Having a nice setup that works ok for production and with sbt-revolver would really help people get started fast. Also a link to a page with other shutdown strategies would be excellent. For example with Tomcat, I believe you can shut down the server while not being the user that owns the process. I imagine a server could be shutdown via a config file changing, or a protected http endpoint being hit. Links to some strategies would really be nice. |
Prefer |
Wasn't aware that existed. (Clearly, I need to make a regular practice of reading the Scala API docs front to back.) Thanks, @viktorklang. |
@bmc You're most welcome, Brian! :) |
Could someone post a snippet of the proper way to block/suspend the main thread when using akka-http from Java? |
It's shown in the above snippet already, please read this ticket |
What's shown above appear to me to be Scala, not Java. Also, the documentation recommends against overriding HttpApp (solution shown above) in favor of using Http.BindandHandle. Additionally, as someone new to Akka and Akka-Http a solution give in context would be valuable. |
Which is what this ticket is about... This ticket would be solved when we write this in the docs. In Java you get a toCompletableFuture() + get() https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.html#toCompletableFuture-- |
I'm an Akka newbie looking at the documentation on https://doc.akka.io/docs/akka-http/current/introduction.html?language=scala#. Agreed that waiting for the user to hit enter on StdIn is not ideal and a pointer to better approaches would be appreciated. |
There was a feedback in Twitter.
https://twitter.com/brianclapper/status/917148072718798848
https://twitter.com/jlprat/status/917149279399108608
Doc samples use readline to wait, which is not recommended in production.
The text was updated successfully, but these errors were encountered: