You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@git.apache.org on 2017/07/28 06:40:08 UTC

[GitHub] wido commented on a change in pull request #2207: [WIP] Embedded jetty inside shaded jar

wido commented on a change in pull request #2207: [WIP] Embedded jetty inside shaded jar
URL: https://github.com/apache/cloudstack/pull/2207#discussion_r130022223
 
 

 ##########
 File path: client/src/org/apache/cloudstack/ServerDaemon.java
 ##########
 @@ -0,0 +1,205 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+package org.apache.cloudstack;
+
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonContext;
+import org.eclipse.jetty.jmx.MBeanContainer;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.NCSARequestLog;
+import org.eclipse.jetty.server.NetworkTrafficServerConnector;
+import org.eclipse.jetty.server.RequestLog;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.handler.HandlerList;
+import org.eclipse.jetty.server.handler.RequestLogHandler;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.eclipse.jetty.util.thread.ThreadPool;
+import org.eclipse.jetty.webapp.Configuration;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/***
+ * Daemon server class to start the embedded server, either through JSVC or directly inside a JAR.
+ * Parameter to configure the jetty server are:
+ * - jetty.port: to start jetty on the specific port (default: 8080)
+ * - jetty.host: to bind to specific interface (default: null = all)
+ * - jetty.requestlog: path to log file for requests (default: request.log)
+ */
+public class ServerDaemon implements Daemon {
+    private static final Logger logger = LoggerFactory.getLogger(ServerDaemon.class);
+    private static final String WEB_XML = "META-INF/webapp/WEB-INF/web.xml";
+    private static final String PROJECT_RELATIVE_PATH_TO_WEBAPP = "src/main/webapp";
+    private static final String REQUEST_LOG = "request.log";
+
+    private Server jettyServer;
+    private int port;
+    private String bindInterface;
+    private String requestLogFile;
+
+    public static void main(String... anArgs) throws Exception {
+        ServerDaemon csServer = new ServerDaemon();
+        csServer.init(null);
+        csServer.start();
+        csServer.join();
+    }
+
+    @Override
+    public void init(DaemonContext context) {
+        Properties props = System.getProperties();
+        setPort(Integer.parseInt(props.getProperty("jetty.port", "8080")));
+        setBindInterface(props.getProperty("jetty.host"));
 
 Review comment:
   To what does *jetty.host* default to? Reason I'm asking is IPv6. Just want to make sure we bind on '::' and not 0.0.0.0 so that IPv6 works out of the box
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services