From db1c748be84c29bc483195439a21e2b9d44da63b Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Mon, 6 Mar 2017 03:30:41 -0800 Subject: Basic http api --- .../src/main/scala/io/crashbox/ci/Main.scala | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'crashbox-server/src/main/scala/io/crashbox/ci/Main.scala') diff --git a/crashbox-server/src/main/scala/io/crashbox/ci/Main.scala b/crashbox-server/src/main/scala/io/crashbox/ci/Main.scala index 0187751..d2e886b 100644 --- a/crashbox-server/src/main/scala/io/crashbox/ci/Main.scala +++ b/crashbox-server/src/main/scala/io/crashbox/ci/Main.scala @@ -1,6 +1,9 @@ package io.crashbox.ci +import akka.http.scaladsl.Http +import akka.stream.ActorMaterializer import java.net.URL +import scala.util.{Failure, Success} object Main extends Core @@ -8,19 +11,22 @@ object Main with Builders with Parsers with Source - with StreamStore { + with StreamStore + with HttpApi { def main(args: Array[String]): Unit = { reapDeadBuilds() - start( - "random_build", - new URL("file:///home/jodersky/tmp/dummy"), - () => saveStream("random_build"), - state => println(state) - ) - Thread.sleep(15000) - System.exit(0) + val host = system.settings.config.getString("crashbox.host") + val port = system.settings.config.getInt("crashbox.port") + + Http(system).bindAndHandle(httpApi, host, port) onComplete { + case Success(_) => + system.log.info(s"Listening on $host:$port") + case Failure(ex) => + system.log.error(ex, s"Failed to bind to $host:$port") + system.terminate() + } } } -- cgit v1.2.3