Skip to content

Commit

Permalink
#4279 - Ability to disable startup notice
Browse files Browse the repository at this point in the history
- Added option to disable startup notice
- Added content-type to startup-notice page
  • Loading branch information
reckart committed Nov 6, 2023
1 parent 0087c6b commit 81aa677
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public class InceptionApplicationContainerConfiguration

private StartupNoticeValve startupNoticeValve;

@Value("${server.startup-notice.enabled:true}")
private boolean statupNoticeEnabled;

@Bean
@Primary
public Validator validator()
Expand All @@ -80,15 +83,15 @@ public TomcatServletWebServerFactory servletContainer()
protected void postProcessContext(Context context)
{
final int maxCacheSize = 40 * 1024;
StandardRoot standardRoot = new StandardRoot(context);
var standardRoot = new StandardRoot(context);
standardRoot.setCacheMaxSize(maxCacheSize);
context.setResources(standardRoot);
}

@Override
public WebServer getWebServer(ServletContextInitializer... initializers)
{
final WebServer container = super.getWebServer(initializers);
final var container = super.getWebServer(initializers);

// Start server early so we can display the boot-up notice
container.start();
Expand All @@ -97,8 +100,10 @@ public WebServer getWebServer(ServletContextInitializer... initializers)
}
};

startupNoticeValve = new StartupNoticeValve();
factory.addContextValves(startupNoticeValve);
if (statupNoticeEnabled) {
startupNoticeValve = new StartupNoticeValve();
factory.addContextValves(startupNoticeValve);
}

if (ajpPort > 0) {
Connector ajpConnector = new Connector(PROTOCOL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
package de.tudarmstadt.ukp.inception.app.startup;

import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ServletException;

import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.http.MediaType;

public class StartupNoticeValve
extends ValveBase
{
@Override
public void invoke(Request request, Response response) throws IOException, ServletException
{
try (InputStream loadingHtml = getClass().getResourceAsStream("startup.html")) {
IOUtils.copy(loadingHtml, response.getOutputStream());
try (var loadingHtml = getClass().getResourceAsStream("startup.html")) {
response.setContentType(MediaType.TEXT_HTML_VALUE);
loadingHtml.transferTo(response.getOutputStream());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,42 @@ These settings relate to the embedded web server in the JAR version of {product-
| Default
| Example

| server.port
| `server.port`
| Port on which the server listens
| 8080
| 18080
| `8080`
| `18080`

| server.address
| `server.address`
| IP address on which the server listens
| 0.0.0.0
| 127.0.0.1
| `0.0.0.0`
| `127.0.0.1`

| server.ajp.port
| `server.ajp.port`
| Port for AJP connector
| -1 _(disabled)_
| 8009
| `-1` _(disabled)_
| `8009`

| server.ajp.address
| `server.ajp.address`
| IP address on which the AJP connector listens
| 127.0.0.1
| 0.0.0.0
| `127.0.0.1`
| `0.0.0.0`

| server.ajp.secret-required
| `server.ajp.secret-required`
| Whether AJP connections require a shared secret
| true
| false
| `true`
| `false`

| server.ajp.secret
| `server.ajp.secret`
| Shared secret for AJP connections
| _unset_
| _some secret string of your choice_

| `server.startup-notice.enabled`
| Whether a self-refreshing startup screen is served while the application is booting before the login screen becomes available
| `true`
| `false`
|===

NOTE: The application is based on Spring Boot and using an embedded Tomcat server. You can configure
additional aspects of the embedded web server using default link:https://docs.spring.io/spring-boot/docs/1.5.22.RELEASE/reference/html/common-application-properties.html[Spring Boot configuration settings].
additional aspects of the embedded web server using default link:https://docs.spring.io/spring-boot/docs/2.7.x/reference/html/application-properties.html[Spring Boot configuration settings].

0 comments on commit 81aa677

Please sign in to comment.