I am using the Armeria framework and I do not find how I can wait on the Armeria server instance until it is shut down.
server.start()
returns a future that completes as soon as the server is running, I am looking for something like server.waitUntilShutdown()
.
Also, if I execute the snippet below as the main()
function of may program, it reaches the end almost immediately.
I would expect the server to be terminated as well, but something keeps the process alive and the web server keeps running until I hit Ctrl+C
.
What threading model does Armeria use behind the courtains? Is it documented somewhere?
final ServerBuilder sb = Server.builder();
sb.http(1234);
// add some services
final Server server = sb.build();
final CompletableFuture<Void> future = server.start()
future.join();
// this point is reached "almost" immediately
I believe you can use the blockUntilShutdown
method
e.g.
Server server = Server.builder().build();
server.start();
// wait until the server is closed
server.whenClosed().join();
// a shortcut
server.blockUntilShutdown();
What threading model does Armeria use behind the courtains? Is it documented somewhere?
Armeria uses Netty extensively under the hood.
By default, server requests will be served via a preconfigured pool of event loops defined by CommonPools.workerGroup()
.