perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

Add support for inherited channels on unixy systems #1186

Open byteit101 opened 3 years ago

byteit101 commented 3 years ago

Issue vs a PR as it can create a new log entry and I wasn't sure if it should be configurable or other api around it.

System services on unixy systems can use socket activation, but that requires jetty to use the inherited channels feature. Spark doesn't enable this feature by default.

The patch for an always-enabled log-producing change is:

----- src/main/java/spark/embeddedserver/jetty/SocketConnectorFactory.java -----
index 16e40dd..1aafbb9 100644
@@ -104,6 +104,7 @@ public class SocketConnectorFactory {
         connector.setIdleTimeout(TimeUnit.HOURS.toMillis(1));
         connector.setHost(host);
         connector.setPort(port);
+        connector.setInheritChannel(true);
     }

     private static HttpConnectionFactory createHttpConnectionFactory() {

Tthe log entry is Unable to use System.inheritedChannel() [null]. Trying a new ServerSocketChannel at 0.0.0.0:8080 if inherited channels are enabled but not usable