Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x Webserver doc and migration guide should explain server beforeStart and afterStop hooks #7956

Open
tjquinno opened this issue Nov 6, 2023 · 0 comments
Assignees
Labels
bug Something isn't working docs webserver
Milestone

Comments

@tjquinno
Copy link
Member

tjquinno commented Nov 6, 2023

Environment Details

  • Helidon Version: 4
  • Helidon SE or Helidon MP
  • JDK version:
  • OS:
  • Docker version (if applicable):

Problem Description

Neither the web server doc nor the migration guide explains how the 3.x WebServer.whenShutdown method has been functionally replaced by the ServerLifeCycle.afterStop method (also available via inheritance on Service and Handler).

The regular doc should at least briefly discuss beforeStart and afterStop and the migration guide should discuss how this 3.x construct in the SE QuickStart Main.startServer method

        webserver.forSingle(ws -> {
            System.out.println("WEB server is up! http://localhost:" + ws.port() + "/greet");
            ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
        })
        .exceptionallyAccept(t -> {
            System.err.println("Startup failed: " + t.getMessage());
            t.printStackTrace(System.err);
        });

can be essentially replaced in 4.x by this in the QuickStart SE Main.main method (for announcing start-up - this code is in the example):

WebServer server = WebServer.builder()
                .config(config.get("server"))
                .routing(Main::routing)
                .build()
                .start();

        System.out.println("WEB server is up! http://localhost:" + server.port() + "/simple-greet");

and by this addition to Greeting.java (this snippet is not in the QuickStart example) for announcing shutdown:

@Override
    public void afterStop() {
        System.out.println("WEB server is DOWN. Good bye!");
    }

(Or, for symmetry, the start-up announcement could be done in a new GreetService beforeStart method instead of in Main.main although the semantics of beforeStart are not quite the same as logging a message after invoking WebServer#start.)

@tjquinno tjquinno added bug Something isn't working docs webserver labels Nov 6, 2023
@barchetta barchetta self-assigned this Dec 18, 2023
@barchetta barchetta added this to the 4.0.3 milestone Dec 18, 2023
@barchetta barchetta modified the milestones: 4.0.3, 4.0.4 Jan 8, 2024
@barchetta barchetta modified the milestones: 4.0.4, 4.1.0 Jan 18, 2024
@barchetta barchetta modified the milestones: 4.1.0, 4.1.1 Aug 1, 2024
@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to Normal priority in Backlog Aug 12, 2024
@barchetta barchetta modified the milestones: 4.1.1, 4.1.2 Aug 26, 2024
@barchetta barchetta modified the milestones: 4.1.2, 4.2.0 Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docs webserver
Projects
Status: Normal priority
Development

No branches or pull requests

2 participants