Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] ServletContextListener defers server start

Why not have a ContextHandler that starts a setup thread on init, and answers 503 until that thread is done?

Bill

On 10/7/19 2:10 AM, Dirk Olmes wrote:
On 10/5/19 2:07 AM, Greg Wilkins wrote:
Dirk,
Hi Greg,

Note that you can actually achieve this with just a little bit of work:

Write a simple context (extend context handler) that all it does is send a
503 with whatever message you want.
Deploy both that context and your context at the same context path.  The
503 context will handle all the requests as it is first.
Once your context is started, stop and/or remove the 503 context.
Thanks for the hint but I'm afraid it is not as simple as you describe -
or I'm still missing bits.

This is what I do for testing:

// this is the handler that just answers 503
ContextHandler duringStartup = new DuringStartupHandler();
// my app
ServletContextHandler theRealContext = ....
HandlerList handlerList = new HandlerList(duringStartup, theRealContext);
server.setHandler(handlerList);

Both handlers participate in the normal server startup, though, which
means that the ServerConnector still does not listen before the real app
context is ready. I'd think that my application context should be
started in a separate thread? Is there anything already present in Jetty
to accomplish this?

The full source of my tests is available here:
https://github.com/dirk-olmes/jetty-delayed-context-startup

-dirk
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users


Back to the top