Skip to content

Commit

Permalink
Move whole app into a Verticle, in attempt to fix #9 using upstream i…
Browse files Browse the repository at this point in the history
…ssue recommendations.
  • Loading branch information
xkr47 committed Jul 27, 2016
1 parent a2c9c30 commit 8a410d9
Showing 1 changed file with 42 additions and 28 deletions.
70 changes: 42 additions & 28 deletions source/org/otherone/vhostproxy/vertx/run.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -333,35 +333,49 @@ shared void run() {

// TODO timeouts
// TODO test responses without body e.g. 204

value myVertx = vertx.vertx();
value client = myVertx.createHttpClient(HttpClientOptions{
connectTimeout = 10;
idleTimeout = 120;
maxPoolSize = 1000;
maxWaitQueueSize = 20;
tryUseCompression = false;
value verticle = MyVerticle();
verticle.deploy(myVertx, null, (String|Throwable res) {
if (is String res) {
log.info("Verticle deployed, deployment id is: ``res``");
} else {
log.error("Verticle deployment failed!", res);
}
});
myVertx.createHttpServer(HttpServerOptions {
compressionSupported = true;
// handle100ContinueAutomatically = false;
reuseAddress = true;
idleTimeout = serverIdleTimeout;
}).requestHandler(ProxyService(client, false, myVertx).requestHandler).listen(portConfig.listenHttpPort);
log.info("HTTP Started on port ``portConfig.listenHttpPort``, sample public url: http://localhost:``portConfig.publicHttpPort``/");
String? keystorePassword;
"Password file not found" assert (is File keystorePasswordFile = parsePath("keystore-password").resource);
try (keystorePasswordFileReader = keystorePasswordFile.Reader("UTF-8")) {
keystorePassword = keystorePasswordFileReader.readLine();
}

shared class MyVerticle() extends Verticle() {
shared actual void start() {
log.info("Verticle starting..");

value client = vertx.createHttpClient(HttpClientOptions{
connectTimeout = 10;
idleTimeout = 120;
maxPoolSize = 1000;
maxWaitQueueSize = 20;
tryUseCompression = false;
});
vertx.createHttpServer(HttpServerOptions {
compressionSupported = true;
// handle100ContinueAutomatically = false;
reuseAddress = true;
idleTimeout = serverIdleTimeout;
}).requestHandler(ProxyService(client, false, vertx).requestHandler).listen(portConfig.listenHttpPort);
log.info("HTTP Started on port ``portConfig.listenHttpPort``, sample public url: http://localhost:``portConfig.publicHttpPort``/");
String? keystorePassword;
"Password file not found" assert (is File keystorePasswordFile = parsePath("keystore-password").resource);
try (keystorePasswordFileReader = keystorePasswordFile.Reader("UTF-8")) {
keystorePassword = keystorePasswordFileReader.readLine();
}
"Password file was empty" assert (exists keystorePassword);
vertx.createHttpServer(HttpServerOptions {
compressionSupported = true;
// handle100ContinueAutomatically = false;
reuseAddress = true;
idleTimeout = serverIdleTimeout;
ssl = true;
keyStoreOptions = JksOptions { password = keystorePassword; path = "keystore"; };
}).requestHandler(ProxyService(client, true, vertx).requestHandler).listen(portConfig.listenHttpsPort);
log.info("HTTPS Started on port ``portConfig.listenHttpsPort``, sample public url: https://localhost:``portConfig.publicHttpsPort``/ . Startup complete.");
}
"Password file was empty" assert (exists keystorePassword);
myVertx.createHttpServer(HttpServerOptions {
compressionSupported = true;
// handle100ContinueAutomatically = false;
reuseAddress = true;
idleTimeout = serverIdleTimeout;
ssl = true;
keyStoreOptions = JksOptions { password = keystorePassword; path = "keystore"; };
}).requestHandler(ProxyService(client, true, myVertx).requestHandler).listen(portConfig.listenHttpsPort);
log.info("HTTPS Started on port ``portConfig.listenHttpsPort``, sample public url: https://localhost:``portConfig.publicHttpsPort``/ . Startup complete.");
}

0 comments on commit 8a410d9

Please sign in to comment.