Bläddra i källkod

[livy] Add option for configuring the scalatra environment

Erick Tryzelaar 10 år sedan
förälder
incheckning
41bed0bf0e

+ 5 - 0
apps/spark/java/conf/livy-defaults.conf.tmpl

@@ -1,3 +1,8 @@
+# Specifies Livy's environment. May either be "production" or "development". In "development"
+# mode, Livy will enable debugging options, such as reporting possible routes on a 404.
+# defaults to development
+## livy.environment = development
+
 # What host address to start the server on. Defaults to 0.0.0.0. If using the
 # What host address to start the server on. Defaults to 0.0.0.0. If using the
 # `yarn` factory mode, this address must be accessible from the YARN nodes.
 # `yarn` factory mode, this address must be accessible from the YARN nodes.
 ## livy.server.host = 0.0.0.0
 ## livy.server.host = 0.0.0.0

+ 5 - 1
apps/spark/java/livy-server/src/main/scala/com/cloudera/hue/livy/server/Main.scala

@@ -19,7 +19,6 @@
 package com.cloudera.hue.livy.server
 package com.cloudera.hue.livy.server
 
 
 import java.io.{File, IOException}
 import java.io.{File, IOException}
-import java.nio.file.{Paths, Files}
 import javax.servlet.ServletContext
 import javax.servlet.ServletContext
 
 
 import com.cloudera.hue.livy._
 import com.cloudera.hue.livy._
@@ -171,6 +170,11 @@ class ScalatraBootstrap
       context.mount(new InteractiveSessionServlet(sessionManager), "/sessions/*")
       context.mount(new InteractiveSessionServlet(sessionManager), "/sessions/*")
       context.mount(new BatchSessionServlet(batchManager), "/batches/*")
       context.mount(new BatchSessionServlet(batchManager), "/batches/*")
       context.mountMetricsAdminServlet("/")
       context.mountMetricsAdminServlet("/")
+
+      context.setInitParameter(org.scalatra.EnvironmentKey, livyConf.get("livy.environment", "development"))
+      context.setInitParameter(ScalatraBase.HostNameKey, livyConf.get("livy.hostname"))
+
+
     } catch {
     } catch {
       case e: Throwable =>
       case e: Throwable =>
         println(f"Exception thrown when initializing server: $e")
         println(f"Exception thrown when initializing server: $e")