Commits

Anonymous committed db16e55

added project

Comments (0)

Files changed (5)

+import com.typesafe.startscript.StartScriptPlugin
+
+seq(StartScriptPlugin.startScriptForClassesSettings: _*)
+
+name := "hello"
+
+version := "1.0"
+
+scalaVersion := "2.9.2"
+
+resolvers += "twitter-repo" at "http://maven.twttr.com"
+
+libraryDependencies ++= Seq("com.twitter" % "finagle-core" % "1.9.0", "com.twitter" % "finagle-http" % "1.9.0")

project/build.properties

+sbt.version=0.12.0

project/build.sbt

+resolvers += Classpaths.typesafeResolver
+
+addSbtPlugin("com.typesafe.startscript" % "xsbt-start-script-plugin" % "0.5.3")

src/main/scala/Web.scala

+import org.jboss.netty.handler.codec.http.{HttpRequest, HttpResponse}
+import com.twitter.finagle.builder.ServerBuilder
+import com.twitter.finagle.http.{Http, Response}
+import com.twitter.finagle.Service
+import com.twitter.util.Future
+import java.net.InetSocketAddress
+import util.Properties
+
+object Web {
+  def main(args: Array[String]) {
+    val port = Properties.envOrElse("PORT", "8080").toInt
+    println("Starting on port:"+port)
+    ServerBuilder()
+      .codec(Http())
+      .name("hello-server")
+      .bindTo(new InetSocketAddress(port))
+      .build(new Hello)
+    println("Started.")
+  }
+}
+
+class Hello extends Service[HttpRequest, HttpResponse] {
+  def apply(req: HttpRequest): Future[HttpResponse] = {
+    val response = Response()
+    response.setStatusCode(200)
+    response.setContentString("Hello World")
+    Future(response)
+  }
+}
 {
+    "packages" : ["openjdk-7-jdk"]
     "custom steps" :
     {
         "get sbt repo" : "wget http://apt.typesafe.com/repo-deb-build-0002.deb",
         "install apt" : "sudo dpkg -i repo-deb-build-0002.deb",
         "apt-get update" : "sudo apt-get update",
-        "install sbt" : "sudo apt-get install sbt"
+        "install sbt" : "sudo apt-get install sbt",
+        "compile" : "sbt clean compile stage"
     }
 }