use of io.helidon.webserver.WebServer in project helidon by oracle.
the class Main method startServer.
/**
* Start the server.
* @return the created {@link WebServer} instance
*/
static Single<WebServer> startServer(Config config) {
// load logging configuration
LogConfig.configureRuntime();
// Build server using three ports:
// default public port, admin port, private port
WebServer server = WebServer.builder(createPublicRouting()).config(config.get("server")).addNamedRouting("admin", createAdminRouting()).addNamedRouting("private", createPrivateRouting()).build();
Single<WebServer> webserver = server.start();
// Try to start the server. If successful, print some info and arrange to
// print a message at shutdown. If unsuccessful, print the exception.
webserver.thenAccept(ws -> {
System.out.println("WEB server is up! http://localhost:" + ws.port());
ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
}).exceptionally(t -> {
System.err.println("Startup failed: " + t.getMessage());
t.printStackTrace(System.err);
return null;
});
return webserver;
}
use of io.helidon.webserver.WebServer in project helidon by oracle.
the class Main method main.
/**
* A java main class.
*
* @param args command line arguments.
*/
public static void main(String[] args) {
// Create a web server instance
int port = 8080;
if (args.length > 0) {
try {
port = Integer.parseInt(args[0]);
} catch (NumberFormatException nfe) {
port = 0;
}
}
WebServer server = WebServer.builder(createRouting()).port(port).build();
// Start the server and print some info.
server.start().thenAccept(ws -> {
System.out.println("TUTORIAL server is up! http://localhost:" + ws.port());
System.out.println("Call POST on 'http://localhost:" + ws.port() + "/mgmt/shutdown' to STOP the server!");
});
// Server threads are not demon. NO need to block. Just react.
server.whenShutdown().thenRun(() -> System.out.println("TUTORIAL server is DOWN. Good bye!"));
}
use of io.helidon.webserver.WebServer in project helidon by oracle.
the class Main method startWebServer.
static WebServer startWebServer() {
// Wait for webserver to start before returning
WebServer server = WebServer.builder(createRouting()).port(8080).build().start().await();
System.out.println("WEB server is up! http://localhost:" + server.port());
return server;
}
use of io.helidon.webserver.WebServer in project helidon by oracle.
the class Main method main.
/**
* A java main class.
*
* @param args command line arguments.
*/
public static void main(String[] args) {
WebServer server = startWebServer();
// Server threads are not demon. NO need to block. Just react.
server.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
}
use of io.helidon.webserver.WebServer in project helidon by oracle.
the class Main method main.
/**
* A java main class.
*
* @param args command line arguments.
*/
public static void main(String[] args) {
WebServer server = WebServer.builder(createRouting()).port(8080).build();
server.start().thenAccept(ws -> System.out.println("Steaming service is up at http://localhost:" + ws.port()));
server.whenShutdown().thenRun(() -> System.out.println("Streaming service is down"));
}
Aggregations