Search in sources :

Example 26 with WebServer

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;
}
Also used : Config(io.helidon.config.Config) WebServer(io.helidon.webserver.WebServer) Single(io.helidon.common.reactive.Single) MetricsSupport(io.helidon.metrics.MetricsSupport) LogConfig(io.helidon.common.LogConfig) Routing(io.helidon.webserver.Routing) HealthSupport(io.helidon.health.HealthSupport) HealthChecks(io.helidon.health.checks.HealthChecks) WebServer(io.helidon.webserver.WebServer)

Example 27 with 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!"));
}
Also used : WebServer(io.helidon.webserver.WebServer)

Example 28 with WebServer

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;
}
Also used : WebServer(io.helidon.webserver.WebServer)

Example 29 with 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) {
    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!"));
}
Also used : WebServer(io.helidon.webserver.WebServer)

Example 30 with 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) {
    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"));
}
Also used : WebServer(io.helidon.webserver.WebServer)

Aggregations

WebServer (io.helidon.webserver.WebServer)88 Config (io.helidon.config.Config)49 Routing (io.helidon.webserver.Routing)48 LogConfig (io.helidon.common.LogConfig)34 Single (io.helidon.common.reactive.Single)17 JsonpSupport (io.helidon.media.jsonp.JsonpSupport)16 MetricsSupport (io.helidon.metrics.MetricsSupport)16 HealthSupport (io.helidon.health.HealthSupport)15 HealthChecks (io.helidon.health.checks.HealthChecks)13 ConfigSources (io.helidon.config.ConfigSources)10 TimeUnit (java.util.concurrent.TimeUnit)10 WebClient (io.helidon.webclient.WebClient)9 WebClientResponse (io.helidon.webclient.WebClientResponse)9 CountDownLatch (java.util.concurrent.CountDownLatch)9 Test (org.junit.jupiter.api.Test)9 Http (io.helidon.common.http.Http)8 MediaType (io.helidon.common.http.MediaType)8 IOException (java.io.IOException)8 SecurityContext (io.helidon.security.SecurityContext)7 StaticContentSupport (io.helidon.webserver.staticcontent.StaticContentSupport)7