Skip to content

Commit

Permalink
Fix link and Future complete
Browse files Browse the repository at this point in the history
  • Loading branch information
amdelamar committed Dec 14, 2017
1 parent f6c0850 commit 01b762f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cloudfoundry-example/README.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
= Vert.x on Cloud Foundry

This demo shows a very simple hello world Vert.x project for link:https://www.cloudfoundry.org/[Cloud Foundry]. It has a simple HTTP server which simply serves the /webroot/index.html.
This demo shows a very simple hello world Vert.x project for link:https://www.cloudfoundry.org/[Cloud Foundry]. It has a simple HTTP server which simply serves the `/webroot/index.html`.

This demo uses link:http://vertx.io/[Vert.x] and is packed using the official link:https://github.com/cloudfoundry/java-buildpack[CloudFoundry java-buildpack]. The `manifest.yml` specifies the app's memory to be 768MB because any lower and the java-buildpack throws an error that it can't allocate enough heap space. (See)
This demo uses link:http://vertx.io/[Vert.x] and is packed using the official link:https://github.com/cloudfoundry/java-buildpack[CloudFoundry java-buildpack]. The `manifest.yml` specifies the app's memory to be 768MB because any lower and the java-buildpack throws an error that it can't allocate enough heap space. (See the link:https://www.cloudfoundry.org/certified-platforms/[list of certified platforms]).

The environment variable `PORT` is normally provided by your CloudFoundry service, and therefore can change when being deployed. Otherwise the default port is `8080`.

Expand Down
8 changes: 5 additions & 3 deletions cloudfoundry-example/src/main/java/hello/MainVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public static void main(String[] args) {

@Override
public void start(Future<Void> startFuture) throws Exception {
super.start(startFuture);

// PORT env check
try {
Expand All @@ -56,15 +55,18 @@ public void start(Future<Void> startFuture) throws Exception {
httpServer.listen(PORT, handler -> {
if (handler.succeeded()) {
logger.info("Listening on port: " + PORT);
startFuture.complete();
} else {
logger.error("Failed to bind on port " + PORT + ". Is it being used?");
String errorMessage = "Failed to bind on port " + PORT + ". Is it being used?";
logger.error(errorMessage);
startFuture.fail(errorMessage);
}
});
}

@Override
public void stop(Future<Void> stopFuture) throws Exception {
super.stop(stopFuture);
logger.info("Stopped listening on port: " + PORT);
stopFuture.complete();
}
}

0 comments on commit 01b762f

Please sign in to comment.