Last active
May 18, 2017 05:53
-
-
Save downgoon/49eaf2e0b569818b624052d199895893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.vertx.config.ConfigRetriever; | |
import io.vertx.core.AbstractVerticle; | |
import io.vertx.core.DeploymentOptions; | |
import io.vertx.core.Future; | |
import io.vertx.core.Verticle; | |
import io.vertx.core.Vertx; | |
public class HelloVerticle extends AbstractVerticle { | |
/* `http.port` can not be allowed in ` ~/.bash_profile` on Mac */ | |
private static final String HTTP_PORT = "HTTP_PORT"; | |
@Override | |
public void start(Future<Void> fut) throws Exception { | |
// Retrieve the port from the configuration, | |
// default to 8080. | |
// int configPort = config().getInteger(HTTP_PORT, 8080); | |
// System.out.println("configPort: " + configPort); | |
// int finalPort = retriever.getCachedConfig().getInteger(HTTP_PORT, 8080); | |
int finalPort = config().getInteger(HTTP_PORT, 8080); | |
System.out.println("finalPort: " + finalPort); | |
vertx.createHttpServer().requestHandler(r -> { | |
r.response().end("<h1>Hello World ! </h1>"); | |
}).listen(finalPort, result -> { | |
if (result.succeeded()) { | |
fut.complete(); | |
} else { | |
fut.fail(result.cause()); | |
} | |
}); | |
} | |
public static void main(String[] args) { | |
Vertx vertx = Vertx.vertx(); | |
Verticle boxcloudVerticle = new HelloVerticle(); | |
// | |
// vertx.deployVerticle(boxcloudVerticle); | |
// new JsonObject().put(HTTP_PORT, 10081) | |
DeploymentOptions options = new DeploymentOptions().setConfig(ConfigRetriever.create(vertx).getCachedConfig()); | |
vertx.deployVerticle(boxcloudVerticle, options); | |
System.out.println("启动..."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.techempower.com/benchmarks/#section=data-r14&hw=ph&test=json