diff options
author | Chris Rebert <code@rebertia.com> | 2014-06-24 12:22:52 +0400 |
---|---|---|
committer | Chris Rebert <code@rebertia.com> | 2014-06-24 12:22:52 +0400 |
commit | fcb65c09915715196421cba4e86e2b5fa28da78e (patch) | |
tree | d125dc361e1808e4aea15c1822b4b0509b2304e0 /src/main/scala/com/getbootstrap/rorschach/server/Boot.scala | |
parent | ed12a1b1d62c9e35e8645c1ef56bd0c13035b59a (diff) |
copypasta from lmvtfy
Diffstat (limited to 'src/main/scala/com/getbootstrap/rorschach/server/Boot.scala')
-rw-r--r-- | src/main/scala/com/getbootstrap/rorschach/server/Boot.scala | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/scala/com/getbootstrap/rorschach/server/Boot.scala b/src/main/scala/com/getbootstrap/rorschach/server/Boot.scala new file mode 100644 index 0000000..dce7a3a --- /dev/null +++ b/src/main/scala/com/getbootstrap/rorschach/server/Boot.scala @@ -0,0 +1,43 @@ +package com.chrisrebert.lmvtfy.server + +import scala.concurrent.duration._ +import scala.util.Try +import akka.actor.{ActorSystem, Props} +import akka.io.IO +import spray.can.Http +import akka.pattern.ask +import akka.routing.SmallestMailboxPool +import akka.util.Timeout +import com.chrisrebert.lmvtfy.github.GitHubIssueCommenter + + +object Boot extends App { + val arguments = args.toSeq + val maybePort = arguments match { + case Seq(portStr: String) => { + Try{ portStr.toInt }.toOption + } + case _ => None + } + maybePort match { + case Some(port) => run(port) + case _ => { + System.err.println("USAGE: lmvtfy <port-number>") + System.exit(1) + } + } + + def run(port: Int) { + implicit val system = ActorSystem("on-spray-can") + // import actorSystem.dispatcher + + val commenter = system.actorOf(Props(classOf[GitHubIssueCommenter])) + val localValidator = system.actorOf(Props(classOf[ValidatorSingletonActor], commenter), "validator-service") + val exampleFetcherPool = system.actorOf(SmallestMailboxPool(5).props(Props(classOf[LiveExampleFetcher], localValidator)), "example-fetcher-pool") + val issueCommentEventHandler = system.actorOf(Props(classOf[IssueCommentEventHandler], exampleFetcherPool), "issue-comment-event-handler") + val webService = system.actorOf(Props(classOf[LmvtfyActor], issueCommentEventHandler), "lmvtfy-service") + + implicit val timeout = Timeout(15.seconds) + IO(Http) ? Http.Bind(webService, interface = "0.0.0.0", port = port) + } +} |