blob: 36686372768865b07dc1981d496e1ead9521d707 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package com.getbootstrap.rorschach.server
import scala.util.{Success,Failure}
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.getbootstrap.rorschach.github.GitHubPullRequestCommenter
object Boot extends App {
val arguments = args.toSeq
val argsPort = arguments match {
case Seq(portStr: String) => {
Try{ portStr.toInt } match {
case Failure(_) => {
System.err.println("USAGE: lmvtfy <port-number>")
System.exit(1)
None // dead code
}
case Success(portNum) => Some(portNum)
}
}
case Seq() => None
}
run(argsPort)
def run(port: Option[Int]) {
implicit val system = ActorSystem("on-spray-can")
val settings = Settings(system)
// import actorSystem.dispatcher
val commenter = system.actorOf(SmallestMailboxPool(3).props(Props(classOf[GitHubPullRequestCommenter])), "gh-pr-commenter")
val prAuditorPool = system.actorOf(SmallestMailboxPool(5).props(Props(classOf[PullRequestEventHandler], commenter)), "pr-auditor-pool")
val webService = system.actorOf(Props(classOf[RorschachActor], prAuditorPool), "rorschach-service")
implicit val timeout = Timeout(15.seconds)
IO(Http) ? Http.Bind(webService, interface = "0.0.0.0", port = port.getOrElse(settings.DefaultPort))
}
}
|