Reputation: 201
I created the vertx httpserver by following java code,
HttpServer htttpServer = vertx.createHttpServer();
htttpServer.setReceiveBufferSize(4 * 1024);
htttpServer.setSendBufferSize(4 * 1024)
.requestHandler(routeMatcher)
.listen(portNo, hostname);
I placed this server code in one my verticle(RestVerticle.java) when i deploy the verticle it starts the server and i am able to see the port is occupied. Now I want to shut down the httpserver programmatically instead of simply pressing ctrl + c. Kindly help me rectify this issue.
Upvotes: 0
Views: 1826
Reputation: 7900
You can programmatically close the HTTP server.
HttpServer server = vertx.createHttpServer();
server.listen(Config.getInt("HTTP_PORT"));
// To stop the server:
server.close();
Upvotes: 2