Browse Source

http4s: Read DBHOST from the environment.

DBHOST is an environment variable, and should be read from there.
Also adds error-level logging to the console (in case the DB tests
fail on the next run).
Gary Coady 9 years ago
parent
commit
871e51956f

+ 1 - 1
frameworks/Scala/http4s/build.sbt

@@ -26,7 +26,7 @@ libraryDependencies ++= Seq(
 	"org.tpolecat" %% "doobie-contrib-hikari" % doobieVersion exclude("com.zaxxer", "HikariCP-java6"),
 	"com.zaxxer" %  "HikariCP" % "2.4.1",
 	"org.postgresql" % "postgresql" % "9.4.1208",
-	"org.slf4j" % "slf4j-nop" % "1.7.18"
+	"ch.qos.logback" % "logback-classic" % "1.1.6"
 )
 
 mainClass in oneJar := Some("http4s.techempower.benchmark.WebServer")

+ 1 - 1
frameworks/Scala/http4s/setup.sh

@@ -4,4 +4,4 @@ fw_depends java sbt
 
 sbt 'oneJar' -batch
 
-java -jar target/scala-2.11/http4s*one-jar.jar &
+java -jar target/scala-2.11/http4s*one-jar.jar "${DBHOST}" &

+ 14 - 0
frameworks/Scala/http4s/src/main/resources/logback.xml

@@ -0,0 +1,14 @@
+<configuration>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- encoders are assigned the type
+         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="error">
+    <appender-ref ref="STDOUT" />
+  </root>
+</configuration>

+ 2 - 3
frameworks/Scala/http4s/src/main/scala/WebServer.scala

@@ -159,10 +159,9 @@ object WebServer extends TaskApp {
   }
 
   // Entry point when starting service
-  override val runc: Task[Unit] = {
+  override def runl(args: List[String]): Task[Unit] = {
     for {
-      dbHost <- Task.delay(System.getProperty("DBHOST", "localhost"))
-      xa <- xaTask(dbHost)
+      xa <- xaTask(args.head)
       server <- startServer(Middleware.addHeaders(service(xa)))
     } yield ()
   }