blob: a610ebe36a20c58572069db00ec2d4508ff962e8 (
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
46
47
48
49
50
51
52
53
54
55
56
57
|
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: rorschach <port-number>")
System.exit(1)
None // dead code
}
case Success(portNum) => Some(portNum)
}
}
case Seq() => None
}
run(argsPort)
def squelchInvalidHttpLogging() {
import org.slf4j.LoggerFactory
import ch.qos.logback.classic.{Logger,Level}
LoggerFactory.getLogger("spray.can.server.HttpServerConnection").asInstanceOf[Logger].setLevel(Level.ERROR)
}
def run(port: Option[Int]) {
implicit val system = ActorSystem("on-spray-can")
val settings = Settings(system)
// import actorSystem.dispatcher
if (settings.SquelchInvalidHttpLogging) {
squelchInvalidHttpLogging()
}
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))
}
}
|