Show maintenance page during Wildfly startup

777 Views Asked by At

I have a WildFly installation which takes some time during startup due to the count and size of the deployments. So I would like to show a maintenance page until the full application is ready.

In one of the previous WildFly versions I used default-web-module as configuration option and registered a small WAR file, which was visible right away and was replaced as soon as the big application was available.

Unfortunately this is no longer possible with WildFly 22, instead an exception is thrown as soon as the real root application is deployed:

org.jboss.msc.service.DuplicateServiceException: Service jboss.undertow.deployment.default-server.default-host./.UndertowDeploymentInfoService is already registered

I know that I could put a small web server (nginx or similar) in front of WildFly to return my maintenance webpage as long as WildFly returns a 503 error. The only thing which prevents that is the fact, that the maintenance page still contains some logic which I would need to emulate on nginx.

Is there any other option which ensures that my maintenance page is delivered immediately while the other apps are still starting?

1

There are 1 best solutions below

3
On

If I do understand your question correctly, what you want is to show error page of status 503 when server is down or 404 when server is replacing deployments.
But for your environment which don't have a web server in front of application server, we just need to consider 404 situation.
503 is for web server when the application server is down, therefore, 503 service unavailable.

First: Console -> Configuration tab

Head over to management console of Wildfly. And depends on what mode(domain or standalone) you are using ,there will be a little different inside configuration tab.

Second: Configuration -> Web -> Filters

If using domain mode, choose the profile you are using it. And head over to Subsystem -> Web(Undertow) -> filters -> click 'View'.

  • I used profile 'full' in my local machine with domain mode, therefore, this is what my console looks like. Path_to_Filters

Third: Choose Error page tab inside Filters

Set code and path like this, where code is what status code you hope the static page to show. And path is the file location of your static page. setPathAndCode

You can see Wildfly doc for error-page settings.

Fourth: Configuration tab -> Web(Undertow) -> Server -> default-server(or what you used)

HeadToServer

Fifth: Choose Hosts tab inside servers

Choose 'Hosts' tab, and click add filter button.
Select the filter we just set in step three, and set predicate to true.

  • I'm not sure what will be effected if didn't set as true or left empty, cause it's not required fields.

Last: Restart the server in order to let your configuration works.
Now you should able to see your static page showed when you undeploy or re-deploy your application.

Sorry for not answering in too good answer format because I didn't answer any questions before.

** You can also set your standalone.xml or domain.xml like this to get the same result. setXmlFile