[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-web/master] Add main class for web server using an embedded jetty.



commit 811e621bab4b162e7c9007fb1a1de0f45533720c
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date:   Mon Dec 4 11:14:41 2017 +0000

    Add main class for web server using an embedded jetty.
---
 .../org/torproject/metrics/web/ServerMain.java     | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/main/java/org/torproject/metrics/web/ServerMain.java b/src/main/java/org/torproject/metrics/web/ServerMain.java
new file mode 100644
index 0000000..882ab80
--- /dev/null
+++ b/src/main/java/org/torproject/metrics/web/ServerMain.java
@@ -0,0 +1,32 @@
+/* Copyright 2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.metrics.web;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.xml.XmlConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ServerMain {
+
+  private static final Logger log = LoggerFactory.getLogger(ServerMain.class);
+
+  /** Starts the web server listening for incoming client connections. */
+  public static void main(String[] args) {
+    try {
+      Resource jettyXml = Resource.newSystemResource("jetty.xml");
+      log.info("Reading configuration from '{}'.", jettyXml);
+      XmlConfiguration configuration
+          = new XmlConfiguration(jettyXml.getInputStream());
+      Server server = (Server) configuration.configure();
+      server.start();
+      server.join();
+    } catch (Exception ex) {
+      log.error("Exiting, because of: {}.", ex.getMessage(), ex);
+      System.exit(1);
+    }
+  }
+}
+



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits