I've wrote a Groovy MainApp with main(args).
When I launch it, the JVM exit directly ("End of JVM execution !").
import org.vertx.groovy.core.Vertx
class MainApp {
public static void main(String[] args) {
Vertx vertx = VertxFactory.newVertx();
vertx.createHttpServer().requestHandler{ request ->
println "A request has arrived on the server!"
}.listen(8080)
println "End of JVM execution !"
}
}
How to run correctly an embedded HTTP server with vert.x?
I had the same problem with Java. I ended up putting an object in .wait() after all the vert.x code. Looks horrible, but actually makes sense because it gives me a trigger to shutdown the server on demand (via .notify()).
This is non trivial, should be mentioned on the Vert.x official documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With