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
  • From: Dirk Olmes <dirk.olmes@xxxxxxxxxx>
  • Date: Mon, 7 Oct 2019 12:34:20 +0000
  • Accept-language: de-DE, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=exentra.de; dmarc=pass action=none header.from=exentra.de; dkim=pass header.d=exentra.de; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xZLIXOf1220nI4HshSMvUUulZFuNVFAHzQ8Dd1ziD34=; b=hLJKzbETvYSFJ032uLoq/G6Fzd3C3vq5H2+PKS8V6bHnEypVrJPSkM/X4gI+nhgCP4m+F37ExfxCfaXhPGBA3Ip7y/aVTdHadKgOVBiiBY00smw6L5oO/QQ9IxzZ1PSblfi7qfmRNjDV0P/uFLFk4ur0a/mkH6M4Sb0jMC6uW5uHoeS/KYM+lXuL/kXH5QQta4X8QI772COTm7318B/bfj4pL4w609AfSLhyxAUWzyZi7nucw1xu8tNmWJ0lbBs4y8KvPiKi8O+6nxGBnuRr0pXK2gMZL/HhOY0mO9Pr7KFAaDklRRxtfbq/DU0jd5TKsDqWp9Di1lmvXPopZZTrVg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rd6ftG4dQPpjCUQ4/Uj+m9V3NumBzGjTKB1+dkKKOfCK+roWda86NPecj8PpEldegLIFNGGSBZYajtZ0nzw+HKHamOVL4KQi4xRCy2boAMWqtyZ2UL2b+kiPomlh0alFBmhWVUQmmq7YVQJSBs37z6juR7IMJCZRi6rhi8KuaHZl0nC98aBbZykpuCnA64YiSeL7c4TaOMes8qnvqOxzQK1MFsj0jje1clGaBMF9ZAizZmlCfGMCNLfAAipC+cu9kEDr4NDNgjVBrPHl7b6MnaJkl6967J0YZYVOJj7AzIiVjxECiYg0DuFX7JjAxd9i3B5oOk4kiOO4owo1zJijtg==
  • Delivered-to: jetty-users@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/jetty-users>
  • List-help: <mailto:jetty-users-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/jetty-users>, <mailto:jetty-users-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/jetty-users>, <mailto:jetty-users-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHVerxZgNVPQSBpKkauFvJnVHLIQadKj9iAgACciACAA93fgP//4VyAgAA2AIA=
  • Thread-topic: [jetty-users] ServletContextListener defers server start

On 10/7/19 11:21 AM, Bill Ross wrote:
> Why not have a ContextHandler that starts a setup thread on init, and
> answers 503 until that thread is done?

That's sort of what I currently do (starting a setup thread from the
main servlet's init method) but that causes all kinds of trouble because
the servlet context accepts requests before all the app logic is ready.

Based on your suggestion combined with Greg's before I came up with this
approach: Register a ContextHandler that answers 503 and let the server
start normally. After the server is started I launch the setup thread
where I register the real app context with the server and manually send
it a start(). After the context is started I unregister the
ContextHandler that answers 503.

The code is here:
https://github.com/dirk-olmes/jetty-delayed-context-startup/tree/deferred_context_startup

Ok, this approach works. But I was hoping that Jetty supported something
like that out of the box.

-dirk


Back to the top