diff options
author | Jakob Odersky <jakob@odersky.com> | 2017-03-06 03:30:41 -0800 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2017-03-06 03:30:41 -0800 |
commit | db1c748be84c29bc483195439a21e2b9d44da63b (patch) | |
tree | 7e8056d53b4206b0314fa83ab5290cdb4d9e4fc5 /crashbox-server/src/main/scala/io/crashbox/ci/Main.scala | |
parent | bd7083167c1a0899f722971fb90ce41c96de252f (diff) | |
download | crashbox-ci-db1c748be84c29bc483195439a21e2b9d44da63b.tar.gz crashbox-ci-db1c748be84c29bc483195439a21e2b9d44da63b.tar.bz2 crashbox-ci-db1c748be84c29bc483195439a21e2b9d44da63b.zip |
Basic http api
Diffstat (limited to 'crashbox-server/src/main/scala/io/crashbox/ci/Main.scala')
-rw-r--r-- | crashbox-server/src/main/scala/io/crashbox/ci/Main.scala | 24 |
1 files changed, 15 insertions, 9 deletions
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() + } } } |