summaryrefslogblamecommitdiff
path: root/crashbox-server/src/main/scala/io/crashbox/ci/Main.scala
blob: 55971b13ad9c1278a07ed2b44a88ae989e989ce3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                      
                                    
 
                              

                                  
 

                
                   

                  

                
                  


                                         
                                             
 

                                                

                                                                
                                             
                         
                                                       

                          
   

 
package io.crashbox.ci

import scala.util.{Failure, Success}

import akka.http.scaladsl.Http
import scala.concurrent._
import scala.concurrent.duration._

object Main
    extends Core
    with Schedulers
    with Storage
    with Executors
    with Parsers
    with Source
    with HttpApi {

  def main(args: Array[String]): Unit = {
    reapDeadBuilds()
    Await.result(setupDatabase(), 10.seconds)

    val host = config.getString("crashbox.host")
    val port = config.getInt("crashbox.port")
    Http(system).bindAndHandle(httpApi, host, port) onComplete {
      case Success(_) =>
        log.info(s"Listening on $host:$port")
      case Failure(ex) =>
        log.error(ex, s"Failed to bind to $host:$port")
        system.terminate()
    }
  }

}